Page 1 of 1

Caching woes

Posted: Mon Jun 13, 2005 11:26 am
by froth
I'm having some severe caching problems... I've made an elaborate signature-switcher for forums that allows users to select your sig on-the-fly with a cool little selection interface. What it does is when the user selects a signature, it rewrites redir.php (which is where the signature's img tag points to) to say:

Code: Select all

header(&quote;Location: SIGLOCATION&quote;)
With SIGLOCATION of course being the url to the sig the user selected. The problem is that the browser caches the image at SIGLOCATION and assumes php is just some image extension (and so has no problem caching) so to actually see the change, the user has to clear his/her temporary internet files or switch browsers or just shift-refresh. To stop the caching, I'm adding anticache headers to redir.php... but to no avail:

Code: Select all

header(&quote;Age: 2147483648&quote;);
header(&quote;Expires: Mon, 31 Dec 2001 23:59:59 GMT&quote;);
header(&quote;Pragma: no-cache&quote;);
header(&quote;Cache-control: no-store, max-age=1&quote;);
The browser still caches the page! When I shift-refresh the forum page with the img tag (the signature) it works fine. But if I just refresh, it gets the image from cache instead of from redir.php. Is there anything I'm missing that I can do from the server-side (obviously my options are limited in the actual html of the forum page), like maybe in htaccess?

Posted: Mon Jun 13, 2005 2:28 pm
by Buddha443556
Been using these header, right out of the manual, to prevent caching. They seem to work.

Code: Select all

// No Page Caching.
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
Have you checked your browser settings? I forgot I changed my settings once and nearly drive myself nuts with a caching bug.

Posted: Mon Jun 13, 2005 3:18 pm
by froth
Hm, it didn't work. :(
No I haven't messed around with any browser cache settings.

Posted: Mon Jun 13, 2005 3:40 pm
by froth
Hm, that's interesting. IE doesn't cache it at all. But Firefox does.

Here's a link to one of my posts: Here
Click my signature to change the sig, then go back and refresh to see if it worked. It works in IE. It doesn't work in Firefox unless you Shift-Refresh the forum page. Also try viewing the location of the signature image and then directing your whole browser window to it... FF doesn't cache that. Thanks!

Posted: Tue Jun 14, 2005 10:45 am
by froth
Just bumping.

Posted: Thu Jun 16, 2005 10:26 pm
by Buddha443556
Might try adding a unique dangle through a redirect:

http://frother6.webpal.info/rotate/froth

redirects to

http://frother6.webpal.info/rotate/froth?random=XXXXXXX

Just an idea ...

Posted: Fri Jun 17, 2005 1:16 pm
by froth
But where would I put it? There would be no way to add a random dangle within the Signature field in my profile...