PDA

View Full Version : Issue with Images' Caching


Mko
08-17-2013, 10:47 AM
Hello,
One of my fellow Administrators has been reporting an odd issue he's been experiencing with my Forum dealing with the caching of images. I've looked around a bunch and can't seem to figure out the cause and how to fix it.

First thing's first: my forum is in a subdirectory on my server (for example purposes, let's say it's in /forum/).
Now, my main page works perfectly fine (aka http://mydomain.com/index.php), and any images updated there do not require my Admin's cache to be emptied (according to him, at least). Now, in my /forum/ subdirectory (http://mydomain.com/forum/), things change.

Below are some examples he has experienced dealing with images' cache:
-When I added custom statusicons to forum sections (using custom prefixes), he was not able to see the new statusicons unless he cleared his cache.
-When I updated the whos_online.gif and stats.gif images in the /misc/ directory, he needed to clear his cache for them to update for him.
-When I tweaked the code in the memberinfo page (two templates specifically: memberinfo_block_ministats and memberinfo_visitormessage) to display avatars not in thumb format (thus without the white background put on transparent avatars, and also without dateline) using only the URL image.php?u=$prepared[userid] and image.php?u=$message[postuserid], respectively, when he changed his avatar, he needed to empty his cache. An odd occurrence was if he replaced his big (100x100) avatar with a smaller (20x20) one, his old avatar image would remain, but it would be shrunken to a 20x20 size.

From what I can conclude, it seems in general any images I change in my /forum/ subdirectory require him to empty his cache for them to update.

I, myself, have never experienced this issue as I normally do not save cache or history on my browser.

To sum up what I need help with: What is the cause of this, and is there any workaround?


Thanks a bunch,
Mark/Mko

kh99
08-17-2013, 12:40 PM
I'm not an expert on this (or even very knowledgeable), but I think it's probably a browser thing. You can configure your web server to set an expiration time for certain file types, like image files, but I think the browser can still do what it wants. And I think browsers cache images even if your server isn't configured to set an expiration. So probably your browser is checking for images being changed every time you load the page, and your admin's isn't, or something like that. I think it's also possible to configure your web server to tell browsers not to cache any images, but I don't think you'd want to do that. When you change a "static" image that isn't meant to change often (like whos_online or stats gifs) then it might take a while for everyone to see the change, but they will see it eventually.

The avatars are another story. An avatar url should really contain a revision number as a parameter if the user has a custom avatar, that way if the user changes it the revision number will change and the browser will see it as a new image. But even if you don't include the revision number, it will update eventually like the other images do.

Mko
08-17-2013, 01:40 PM
Ah, thanks for the reply. I just went through the 4 classes that use one of the fetch_avatar functions and set the thumb param to false and they display perfectly (no issues with the cache). As for the other images, I guess they don't change often at all, so there should be no worry there.

Thanks again :)