aboutsummaryrefslogtreecommitdiff
path: root/engine/handlers/cache_handler.php
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-04-16 11:52:37 -0400
committerBrett Profitt <brett.profitt@gmail.com>2011-04-16 11:52:37 -0400
commit309dff2bf948ab191ccb1e8d4a777e49ad498820 (patch)
tree813350181be64e239287c0bb587a3a49320a49b7 /engine/handlers/cache_handler.php
parent119ec1f1425ab77ed29c696d99c0c80df3886791 (diff)
parent2b2afd98c05139c1a5c25f1752e2bb412e26e335 (diff)
downloadelgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.gz
elgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.bz2
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'engine/handlers/cache_handler.php')
-rw-r--r--engine/handlers/cache_handler.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php
index 05c35171b..7d6f42dc3 100644
--- a/engine/handlers/cache_handler.php
+++ b/engine/handlers/cache_handler.php
@@ -3,7 +3,7 @@
* Cache handler.
*
* External access to cached CSS and JavaScript views. The cached file URLS
- * should be of the form: cache/<type>/<view>/<viewtype>/<unique_id> where
+ * should be of the form: cache/<type>/<viewtype>/<name/of/view>.<unique_id>.<type> where
* type is either css or js, view is the name of the cached view, and
* unique_id is an identifier that is updated every time the cache is flushed.
* The simplest way to maintain a unique identifier is to use the lastcache
@@ -50,13 +50,16 @@ if (!$request || !$simplecache_enabled) {
echo 'Cache error: bad request';
exit;
}
-$request = explode('/', $request);
+// testing showed regex to be marginally faster than array / string functions over 100000 reps
+// it won't make a difference in real life and regex is easier to read.
+// <type>/<viewtype>/<name/of/view.and.dots>.<ts>.<type>
+$regex = '|([^/]+)/([^/]+)/(.+)\.([^\.]+)\.([^.]+)$|';
+preg_match($regex, $request, $matches);
-//cache/<type>/<view>/<viewtype>/
-$type = $request[0];
-$view = $request[1];
-$viewtype = $request[2];
+$type = $matches[1];
+$viewtype = $matches[2];
+$view = $matches[3];
switch ($type) {
case 'css':