0

Ok, this is starting to annoy and Google has yet to provide any clear answers.

I'm dynamically creating CSS based on users choice of theme colours. Easy enough, done with PHP but the code is irrelevant here, the problem being that IE is caching the old CSS and upon loading a theme it's not producing the new CSS without an F5 refresh. Firefox, Chrome and Safari all produce the desired effect.

I'm sure it's something simple I'm overlooking but for the sake of my sanity please clue me in.

Cheers,

Dalefish

4
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by MidiMagic
0

Simple solution, especially if you're using PHP would be to add a timestamp to the end of the filename. E.g.

stylesheet.css?t=1234567890

This will result in the stylesheet link being different everytime, hence the browser cannot cache the file :)

Hope this helps.

R.

0

Sillyboy, tried a refresh, and using a third page with a redirect before posting neither worked, but thanks for the answer.

Robothy, simple yet effective, thanks.

0

This is a setting in the browser, not your code. Each user has to turn off the caching of pages and/or enable checking for changed files.

0

MidiMagic, The solution of generating a random URL extension, either time-stamp or otherwise, as suggested by robothy, has worked for me.

url now reads: style_user.css?t=0.84755300 1234945905
file remains: style_user.css

The timestamp is generated with PHP and inserted as a variable (for anybody else needing a similar solution).

0

I suppose the best solution would be to use the timestamp for when the file was last modified. Then caching can take place if the file is the same. If the file has been modified, obviously you need to override the caching.

MidiMagic, if it is a browser setting which cannot be overridden from the server side, surely that would mean websites could never be updated by their developers?

R

0

MidiMagic, if it is a browser setting which cannot be overridden from the server side, surely that would mean websites could never be updated by their developers?

No, just that the user needs to hit the refresh button to update the cache.

This is usually set to minimize download traffic on dial-up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.