views:

28

answers:

1

Hey all,

I have a php script that loads a CSS stylesheet, changes the color attribute and then creates a new CSS file with the new color and links it to the page.

When I hit refresh it sometimes updates to reflect the changes, sometimes it doesn't. At first I thought it was the cache, so I disabled caching in Safari but its still happening.

I was wondering if any of you have come across this, and if you have a solution for me.

Thanks! Matt

+2  A: 

CSS is notorious for caching. Even what you did may not stop it from caching

A surefire way to reload the CSS is to do this:

<link rel="stylesheet" type="text/css" href="MyStylesheetScript.php?version=1" />

Simply ignore the query string in your sript. Changing its value (2, 3, 4) each time that you change the CSS will force all browsers to reload the CSS.

If it doesn't change after that, then the problem is your CSS :)

Stargazer712
Thanks for your comment. Unfortunately I already did that. with `'?'.time()`
Matt
It does change it just doesn't always update with the reflected changes.
Matt
Then I'm afraid that the problem is probably your CSS.
Stargazer712
You're the man. It took me 4 hours to realize how baller you are. You're right it was my css. I was randomly generating IDs and it failed when my ids started with a number (ie. `button#5fGz`)
Matt
You are walking down a well traveled path :)
Stargazer712