Is there a way to get user browsers to refresh CSS/cache after CSS file changes on website? 
Posted: 17 June 2008 06:51 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  332
Joined  05-15-2007

Hi there,

We’ve noticed that when we make changes to our CSS file, the changes aren’t always picked up in browsers until the user does a forced refresh.  This is fine for testing as we know to do this, but what about our website visitors who aren’t all so web savvy?

How can we ensure that changes to the CSS file are picked up by their browsers?  i.e. Is there a way to tell the browser to refresh its cache?  Without forced refreshing (CTRL + F5) we’ve even had our own staff call us up saying things we’re not aligned correctly after us making changes.

Thanks for any advice on this,

Stephen

Profile
 
 
Posted: 17 June 2008 08:21 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  888
Joined  06-05-2007

Add:

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

to your head data.

EDIT
==================================

And/Or do this number to your pages.

EDIT
==================================

You could even do this too:

<meta http-equiv="cache-control" content="no-cache" />
<
meta htttp-tquiv="pragma" content="no-cache" />
<
meta http-equiv="expires" content="0" />

 Signature 

grantmx | designs - design | development | photography | consulting | ee pro profile

Profile
 
 
Posted: 17 June 2008 08:59 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  332
Joined  05-15-2007

Thanks for this, much appreciated! grin

Stephen

Profile
 
 
Posted: 17 June 2008 09:32 AM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4897
Joined  04-15-2006

You realise that if you use the stylesheet global variable that it has in-built caching though?

This means that when you take a look at the link for the stylesheet you will see something like this :

ttp://localhost:8888/ee/index.php?css=site/site_css.v.1212323607

When you update your CSS template then the numbers a the end of the URL should change which they are just acting like a random number appended to it and so when that number changes it should automatically (hopefully) force the browser to load the new version as it will have a different name.

Don’t know if that helps in this situation at all though?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!!
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 17 June 2008 09:56 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  888
Joined  06-05-2007

Oh yeah. Didn’t realize that one… smile And yet a 4th option!

 Signature 

grantmx | designs - design | development | photography | consulting | ee pro profile

Profile
 
 
Posted: 17 June 2008 10:16 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  332
Joined  05-15-2007
Mark Bowen - 17 June 2008 09:32 AM

You realise that if you use the stylesheet global variable that it has in-built caching though?

This means that when you take a look at the link for the stylesheet you will see something like this :

ttp://localhost:8888/ee/index.php?css=site/site_css.v.1212323607

When you update your CSS template then the numbers a the end of the URL should change which they are just acting like a random number appended to it and so when that number changes it should automatically (hopefully) force the browser to load the new version as it will have a different name.

Don’t know if that helps in this situation at all though?

Best wishes,

Mark

Hi Mark,

We were using this already but found that it wasn’t working! :-(

Thanks,

Stephen

Profile
 
 
Posted: 17 June 2008 10:30 AM   [ Ignore ]   [ # 6 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4897
Joined  04-15-2006

In what way didn’t it work. Have used this on a few sites now and it seems to always refresh when I make any changes. I know there have been a few issues with it so maybe you are experiencing one of those.

Are you placing your CSS into external files then? If so you may be able to force what you want by appending a random number to the end of the filename perhaps?

Maybe use php or something to tack on the seconds since epoch or something as that will always be different?

Don’t know if that is any good though?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!!
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 17 June 2008 12:00 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  332
Joined  05-15-2007

Basically, we added in an image graphic onto a page and had styles in the CSS file to position it, but when staff went to the site, they found that it wasn’t positioned properly (at all).

We’re definitely using the EE tag for the CSS file as you mentioned above, rather than calling an external file.  So the number after the CSV file link should have been changing, but this still required the forced refreshes, hence why I posted here for some alternative ideas.

Anyway, we’ll experiment with the meta tags above and see how we get on.

Thanks Mark,

Stephen

Profile
 
 
Posted: 29 July 2008 12:09 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  523
Joined  12-10-2006

Mark, Stephen - You are both right.

I think the css version number takes effect only when you update the template via the CP.

I have my templates saved as files, and have tested whether the css version number updates after I save my css file, and it does not.

However, if I change the same css file via the CP, the version number updates.

Can an EE rep please check to see if this is the case, and if so, determine if it’s a bug or intended behaviour.

If this is the intended behaviour, I will add a feature request to have the css version number update when saving templates as files.

Blessings guys
- Ad

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 60712 Total Logged-in Users: 20
Total Topics: 73164 Total Anonymous Users: 13
Total Replies: 394607 Total Guests: 521
Total Posts: 467771    
Members ( View Memberlist )