Forum Moderators: open

Message Too Old, No Replies

Firefox caching issue

May not be FF

         

rocknbil

8:13 pm on Jul 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me preamble this with the fact that it may NOT be FF, I recently switched ISP's and it may be a function of the proxy server.

All satellite providers, to my knowledge, are proxy servers. It's just the way it works. For those that don't know, a proxy server caches it's own copies of files at the NOC, retrieving new ones only if it recognizes the source file has changed. Which it often doesn't.

I'll upload a change to a CSS external sheet. Delete private data (clear FF cache.) Reload the page. Usually, the changes take effect.

But here's what's annoying: refresh the page, and often the OLD style sheet will come back, even though the cache was cleared. Sometimes I'll get it updated, then begin working on content, changing only the page, not the CSS. Two or three refreshes in, the style sheet from before refreshing kicks in. Maddening.

Doesn't appear to happen in IE, oddly enough. So now I have to do a filename change with every update: filea.css, fileb.css, filec.css, to guarantee it updates during development. And even then, as mentioned, one of the old ones will take effect.

Anyone else have this kind of oddity? Is there some method to force proxy servers to do what I tell them to? :-)

jdMorgan

9:52 pm on Jul 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What *do* the cache-control headers you configured on your server tell them to do?

Generally, if you set Cache-Control: "no-cache, must-revalidate"
you won't see this kind of problem.

(Note that "no-cache" doesn't mean "don't cache" -- It has suffered from "definition drift" over time. In order to stop caching, you now must use "no-store." So the above code usually will result in 304-Not Modified responses if you have not updated the page, and then only if the browser actually sends a request.)

Also take a look at your "Expires" settings to be sure you're not setting some over-long expiry time -- or worse yet, not setting one at all (which leaves it up to the browser and/or intervening caching proxies to decide).

I'll guess that your ISP uses multiple load-shared caching proxies, and that you may be getting a different one after two or three page reloads. You might also look into disabling "public" (proxy) caching and allowing only "private" (browser) caching in your Cache-Control header.

These cache-control and expires settings vary widely, and there is no "best answer" -- But you might want to experiment to see where the stale cached data is coming from, and what point on the freshness vs. server load curve makes you most comfortable.

Jim

rocknbil

12:21 am on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As usual Jim, very helpful! and mind boggling for me.

I will check and verify with my admin. However, it's notable to mention, I'm getting this on multiple projects and servers that I do, and do not, have control over configuration. I can sure try to fix the ones that I do . . . .

encyclo

12:43 am on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The quickest and easiest method of avoiding caching is to change the file name of the CSS file every time it's modified. It's easy enough if you are using a global include for the head section of your site.

One easy way of doing this I've come across recently is to add a query string onto the

link
declaration which adds a datestamp, so when the CSS file datestamp changes, the browser sees it as a new filename. eg. in PHP:

$cssfiletime = filemtime(dirname(__FILE__) . '/server/root/path/css/style.css');
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/mystyle.css?$cssfiletime\">\n";