views:

33

answers:

1

How can I change cachable content so that the user will immediately get the refreshed version?

I'll give an example: I have a .css file that is cachable for 2 weeks, so even if I change it, users will still get the old version, unless the press F5.

There are a few solutions, that I know of, but none are perfect:

  • Changing the filename (from main.css to main2.css).
  • Adding a unique URL parameter (like main.css?v=1).

I think that this could somehow be solved using apache eTags and I tried once with that but no luck.

A: 

Maybe this is way off, but doesn't bouncing apache clear its cache?

Something like: /usr/sbin/apachectl graceful perhaps?

Better yet, are you using apache itself for caching, or something else like squid?

I run apache 'normally', and when I make changes to css or other files (outside of scripts), just loading the page in my browser (like by clicking the "home" button), the browser shows the old version. Sometimes this is true even when I press F5. The only way I know to force the browser to truly reload is with Ctrl-Shift-R (on Windows) or Cmd-Shift-R (Mac OS).

warren
This is not a viable solution for me, why should I restart apache just for this? Also, I'm on a shared server, so that's out of the question.
duality_