I am using timThumb that has a cache engine. As the script/tutorials say, you have to have a cache file with permission 0777. This is what I have already.
When an image is viewed in the page, using the below
timthumb.php?src=http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg
it creates a 9c9313eced007f38eb59791dad91edb1.jpg file in the cache folder.
I checked the image and it is the same I saw. On my next refresh, I view the page source and I get again
timthumb.php?src=http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg instead of the cached image.
My question is, shouldn’t show a domain.com/9c9313eced007f38eb59791dad91edb1.jpg ?
This is the code I use http://codepad.org/pVzET9Dv ( It is a modified version to accept all domains )
Note: I tried it also with the official release, but again the same. Maybe it’s how cache works, I don’t know.. But if is so, how can I check that what I saw is the cached?
You have the wrong idea about the concept of caching here.
Notice that when a file is in the
cache_dir, php checks whether the user has sent him the headerHTTP_IF_MODIFIED_SINCE.If the browser sends this header, then this means that the browser has a local copy of this file which has had a
Last-Modifiedvalue ofHTTP_IF_MODIFIED_SINCEwhen it was downloaded.Now, if this date is the really the last modification date of the image, the server sends the header
HTTP/1.1 304 Not Modified.Notice the check in function
show_cache_file.One more thing, it seems php is re-sizing the image and saving the re-sized image in its own cache folder. So in this way, the re-sizing process is not repeated again.
I am not aware whether there is a browser that allows you to know if a displayed image is fetched from cache or downloaded. Anyway this is irrelevant since the user must be sure that it is the most recent image.