FF 3+ has some weird caching issues. I have that problem on multiple sites.
http://www.west-wind.com/Weblog/posts/469125.aspx
Thanks Ipstenu, I was not aware of this issue in Firefox, presumably because I hadn’t upgraded until recently. The link you sent refers primarily to cache issues posing problems for developers trying to see updates–I’m surprised this issue doesn’t cause problems for more sites that require login for full access to content, like any forum software. If Firefox caching pages and not refreshing is causing this problem it seems this must be happening to the bbpress community at large. Is this something other BBPress folks are having issues with?
Well on further consideration I looked at the source on this forum and noticed they are placing a random number to the end of the style sheet. Notice what is currently line 5 of the source of this page:
<link rel=”stylesheet” href=”https://bbpress.org/forum-theme/bborg/style.css?v=2047769217″ type=”text/css” />
So, I decided the bbpress.org developers had the same difficulties with FF3.0. I tried the same thing myself and I can now log in perfect now, so I guess that is the fix. I would still love to hear from anyone else if they’ve had this issue as well though.
Actually that’s an old trick from IE and it’s moronic ‘You have to delete everything to get IE 6 to dump css cache!’ days.
I update that v number every time I make a change to my code, which is a pill, but … yeah, that would do it.
I can’t believe that FF has devolved like that. BAD FF! No cookies!
FYI, for those who are lost, you’d do something like this:
<link rel="stylesheet" href="style.css?v=<?php echo mt_rand(); ?>" type="text/css" />
You don’t want to change that number on every page load, or the CSS file will never ever cache at all and slow down page load / render.
In theory the best number to append would be the timestamp of the CSS file itself, meaning if the CSS file was edited/saved, the number would change, hence force the cache to update. filemtime
gives you the file date. The problem with using it is that on some systems it can be relatively slow and add overhead to the page load time.
Alternately you could use today’s date, or even the current hour, ie ?".date('G');
If you are seeing overly aggressive caching of certain files, it probably means the server has been setup that way and can be changed, at least on apache via htaccess
_ck_ – I’ve seen it on pretty much every site since I upgraded to FF 3
But yeah, good point. You could do this <?php echo getlastmod('style.css'); ?>
(filemtime is cached which would kind of defeat the purpose)
If the only issue were updating the cache when edits were made last mod date would work, but the issue I’m having is the login box still appearing on cached pages after logging in. This makes it look like the login didn’t work even though it did (refresh the page and all is good again). Maybe I could append something to style.css only if the user is logged in allowing caching to work otherwise, although the whole thing still makes me feel dirty.
I think it’s odd that more people don’t seem to be having this problem which makes me think there is something unusual in header information provided by the server to Firefox or like _ck_ said some aggressive server side caching that somehow only Firefox is picking up on.