stacey
stacey copied to clipboard
JSON never retrieved from cache
I may be mistaken but is it possible that this change may have caused caching to no longer work for JSON files?
Specifically the cache IS correctly written for JSON files but the lack of identifying comment containing the md5 within the cache file causes it never to be retrieved from the cache, causing all non-403d JSON requests to be re-rendered fully (which in my case is very slow because I am generating a list of all images across the site)
I suspect that this is the culprit (line 57 of cache.inc.php)
function get_current_hash() {
preg_match('/Stacey.*: (.+?)\s/', file_get_contents($this->cachefile), $matches);
return isset($matches[1]) ? $matches[1] : false;
}
If I remove 'json' from the $no_comment_types array, caching for JSON files resumes as normal, but of course the produced JSON is invalid because of the comments at the end.
I can't think of an easy fix considering the current caching mechanism appears to rely on the md5 being matched against within the comment at the end of each cached file.
Ideas?
Actually I came up with a fairly quick tweak that solves this issue: https://github.com/kolber/stacey/pull/38
I haven't removed all of the commenting from cachefiles (even though it is no longer necessary) because it is perhaps useful for testing.