Web Hosting Talk







View Full Version : How do I force reload of updated CSS after site design changes


hellind2
05-04-2007, 11:29 PM
Hello,

I have updated the layout of my site and changed the CSS. The new design will look broken with the cache CSS. How do I force a reload of the updated CSS?

One option is to change the name of the CSS file but it is tedious to do it to every files across the site.

Any suggestions?

Greedisgood
05-04-2007, 11:43 PM
Try clearing your cache :)

hellind2
05-04-2007, 11:46 PM
Oh! I as a webmaster know to Ctrl+Reload. But my website visitors are not web-savvy, they will get turned off with a broken layout.

How to force reload on their browser?

djseamus
05-05-2007, 02:54 AM
One thing you can try is to insert a meta tag into your html code:

<meta http-equiv="pragma" content="no-cache"></meta>

Not sure if it'll work but it's worth a try...

djseamus
05-05-2007, 02:58 AM
Oh! I as a webmaster know to Ctrl+Reload.

What about Ctrl+Shift+Reload?

killapix
05-05-2007, 07:15 PM
how about meta refresh.?
Force the visitors browser to refresh the page when they next visit.?

<!-- Refresh page after 10 seconds -->
<meta http-equiv="refresh" content="10" />

fastnoc
05-05-2007, 07:26 PM
a meta refresh is just going to refresh the same page I'm guessing

Forcing no cache does make sense.

but I could be wrong of course.

rl421403
05-05-2007, 07:35 PM
i dont think this is gonna work unless you do some php chache refresh.

killapix
05-06-2007, 06:34 AM
Forcing no cache does make sense. <meta http-equiv="pragma" content="no-cache"></meta>



Although a few caches may honor this header, the majority won’t, and it won’t have any effect.
Go with cache-control headers they will give you full control of how you want the site to be handled by the cache and allows you to set time and conditions for re-validation.

fastnoc
05-06-2007, 07:44 AM
That's interesting. I didn't know most browsers won't follow that rule. It's good to know.

Thanks!

sasha
05-06-2007, 11:08 AM
You can run in the same situation with JS includes.

The safest way to force change it to use differetn file name or something like this

.... href="file.css?v=1000" ....
and
.... src="file.js?v=1000" ....

after you update files, you just bump the version number and browsers will retry to fetch the file.

There are few variation on the topic. You could use server side scripting to set ?v=xxxx part at actual time when file was last modified (there is performance penalty for this but it would not be noticeable on the site that is not too busy), or you could use something like this
.... src="file_1000.js" ....
and then use mod_rewrite to redirect to proper file file.js.