12 replies [Last post]
HellsBells
HellsBells's picture
Offline
Leader
Bedford, UK
Last seen: 11 years 32 weeks ago
Bedford, UK
Joined: 2004-04-07
Posts: 851
Points: 0

Hi everyone

I'm just updating a site and have changed the stylesheets.

To avoid getting a blank page with just text the first time it's looked at all the regular users are going to have to clear their caches - is there a way round this - a way of forcing the new stylesheet and avoiding the white page?

Thanks

My strategy is so simple an idiot could have devised it!

"Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

Spectralizer
Spectralizer's picture
Offline
Enthusiast
Toronto, ON. Canada
Last seen: 14 years 37 weeks ago
Toronto, ON. Canada
Timezone: GMT-5
Joined: 2005-03-30
Posts: 53
Points: 0

cache clearing

I'm not a "pro" so I might be wrong or there might be a better way, but the only thing I know that would do the trick is an "expire" meta-tag.

<META name="Expires" content="Tue, 01 Jun 1999 19:58:02 GMT">

in the HEAD of your document should cause the page to load fresh as long as you use a date that's in the past Smile At the least I think it'll do a checksum to verify if the page contents are new or cached....

Can anyone verify the actual behaviour?

Apparently search engines will delete your page if the tag shows expired, however -- I don't have any experience with this, it's just what I'm reading right now based on this search:

http://www.google.ca/search?hl=en&q=expire+meta+tag&btnG=Google+Search&meta=

<META name="Revisit-After" content="X Days">

Where "X" is a numeral will get the search engines to come back, according to the first page I checked on the topic.

This is my .sig... there are many like it, but this one is mine.
My .sig is my best friend... It is my life.
I must master it as I must master my life.
My .sig, without me, is useless... Without my .sig, I am useless.

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 7 years 12 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

cache clearing

Ensure the new style sheet has a different name from the old one. Then when they load the new page they will not have the required stylesheet cached.

You can use a multi-file search and replace to alter the style sheet name in all your web pages. Dreamweaver can do that as can Textpad and probably a whole host of other apps, including some esoteric use of grep.

red58
Offline
Regular
Canada
Last seen: 12 years 40 weeks ago
Canada
Joined: 2005-03-21
Posts: 38
Points: 0

cache clearing

just insert this meta tag for a week or 3:
<meta http-equiv="refresh" content="5"> 5 = number of seconds til the browser will reload the page

Bill

HellsBells
HellsBells's picture
Offline
Leader
Bedford, UK
Last seen: 11 years 32 weeks ago
Bedford, UK
Joined: 2004-04-07
Posts: 851
Points: 0

cache clearing

Chris..S wrote:
Ensure the new style sheet has a different name from the old one. Then when they load the new page they will not have the required stylesheet cached.

the stylesheets have the same name - but a different path as I moved it into a different folder. The default sheet (structural layout) is showing but the preferred one (images etc) is not showing until the cache is cleared.

My strategy is so simple an idiot could have devised it!

"Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

HellsBells
HellsBells's picture
Offline
Leader
Bedford, UK
Last seen: 11 years 32 weeks ago
Bedford, UK
Joined: 2004-04-07
Posts: 851
Points: 0

cache clearing

red58 wrote:
just insert this meta tag for a week or 3:
<meta http-equiv="refresh" content="5"> 5 = number of seconds til the browser will reload the page

Bill

Thanks for this - does this have a "down side" at all? Will the increased calls to the server impact on bandwidth as they're fairly pushed as it is?

Also - can I just put it on the index.html page - will this do the trick for the rest of the site too (plus they'll move from there to another page fairly quickly so helping with my previous worry)?

Thanks for all your suggestions

My strategy is so simple an idiot could have devised it!

"Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 7 years 12 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

cache clearing

Does a meta http-equiv="refresh" force a style sheet refresh (and images too).

I would have thought, there is a real argument for ensuring new versions of page components - style sheets, images, objects, javascripts - all having new names when updated just to avoid this problem.

Having a different set of names also means there will never be any problems with cached/mirrored pages pulling incorrect content. Or in reverting to old versions of web pages in case of issues during the update. Disk space to store things isn't exactly at a premium and a sensible naming convention will avoid problems with maintenance. Keeping the names the same is more of a developer convenience than a user one.

HellsBells
HellsBells's picture
Offline
Leader
Bedford, UK
Last seen: 11 years 32 weeks ago
Bedford, UK
Joined: 2004-04-07
Posts: 851
Points: 0

cache clearing

Chris..S wrote:
Does a meta http-equiv="refresh" force a style sheet refresh (and images too).

I would have thought, there is a real argument for ensuring new versions of page components - style sheets, images, objects, javascripts - all having new names when updated just to avoid this problem.

Having a different set of names also means there will never be any problems with cached/mirrored pages pulling incorrect content. Or in reverting to old versions of web pages in case of issues during the update. Disk space to store things isn't exactly at a premium and a sensible naming convention will avoid problems with maintenance. Keeping the names the same is more of a developer convenience than a user one.

Don't suppose same name but different path counts as a change of name does it?

My strategy is so simple an idiot could have devised it!

"Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 7 years 12 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

cache clearing

HellsBells wrote:
Don't suppose same name but different path counts as a change of name does it?

Yes it does Smile

As long as you are telling the browser to get a file it hasn't got in its cache you will be ok.

HellsBells
HellsBells's picture
Offline
Leader
Bedford, UK
Last seen: 11 years 32 weeks ago
Bedford, UK
Joined: 2004-04-07
Posts: 851
Points: 0

cache clearing

Chris..S wrote:
HellsBells wrote:
Don't suppose same name but different path counts as a change of name does it?

Yes it does Smile

As long as you are telling the browser to get a file it hasn't got in its cache you will be ok.

well that's what I'd done originally - oh b****r - I've just been through and changed it all!

Even with the new path people were still getting a blank site unless they emptied their cache - and some seem to have a lot of trouble doing that!

My strategy is so simple an idiot could have devised it!

"Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH

briski
briski's picture
Offline
Elder
London
Last seen: 7 years 26 weeks ago
London
Timezone: GMT+1
Joined: 2004-02-16
Posts: 1066
Points: 0

cache clearing

You should be able to get them to press ctrl + f5 which should force the browser to get all the things affress no?

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 6 years 20 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

cache clearing

Reading this thread through, it seems to me that the problem is with images being cached, not stylesheets - yes/no?

In which case, don't forget that ISPs often cache images as well as browsers. In fact, your images may being cached in numerous places between the server and the end user. Nightmare!

I think I'm right in saying that the only way to force an image update at the browser (other then a change of file name or asking the user to shift-refresh) is via the headers, but I'm not clever enough to know how to do this.

Refreshing the page every 5 seconds using a meta tag will not force any caches to refresh AFAIC, and anyway, do you really want the user to have to watch the page reloading every 5 seconds? Think about it!

If anyone can explain how to force an image cache refresh via the headers, I for one am all ears Smile

Life's a b*tch and then you die!

HellsBells
HellsBells's picture
Offline
Leader
Bedford, UK
Last seen: 11 years 32 weeks ago
Bedford, UK
Joined: 2004-04-07
Posts: 851
Points: 0

cache clearing

roytheboy wrote:
Reading this thread through, it seems to me that the problem is with images being cached, not stylesheets - yes/no?

It's both.

I have a default stylesheet with layout and structure but no colours, images, etc. which shows up fine.

The problem is the preferred stylesheet with colours and images doesn't show until the cache is cleared.

I'm just trying to avoid the inevitable "nope didn't work - can't see the site" thing that can go on and on... it's frustrating!

My strategy is so simple an idiot could have devised it!

"Also, your CSS (no offence) makes me want to gouge my eyes out with a rusty spoon" - TPH