CSS question

For discussions about game development that does not fit in any of the other topics.
Post Reply
Zyviel
Posts: 75
Joined: Tue Jun 08, 2010 8:12 pm

CSS question

Post by Zyviel »

I've noticed that when I make a change to my css file and save it, the web page that uses the css file does not show the changes when I first load it up. I have to right click on he page and choose reload and then the css changes show up.

I was wondering if anyone else has experienced this issue with css? Is there a way I can make the css changes take effect without having to load the page and then right click and choose reload?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: CSS question

Post by hallsofvallhalla »

using Firefox?

Most likely it is the browser, It is cache'ing the files, or rather storing it in temp folder then pulling it instead of the new file.
Zyviel
Posts: 75
Joined: Tue Jun 08, 2010 8:12 pm

Re: CSS question

Post by Zyviel »

Thanks for the response Halls. Yes I use firefox for my browser. I agree the browser is caching the files and not loading the changes. Was hoping that I could override that caching somehow so the user doesn't have to right click the page and choose reload.

I understand that browser caching of pages serves a useful purpose it just seems strange to me that the css file isn't checked for changes.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: CSS question

Post by hallsofvallhalla »

not sure why it is not, my does...maybe a setting?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS question

Post by Jackolantern »

F5 simply reloads a page in Firefox. However, Ctrl+F5 will erase the cache and completely reload the page. Try that if your cache is preventing up-to-date views of your webpage.
The indelible lord of tl;dr
Zyviel
Posts: 75
Joined: Tue Jun 08, 2010 8:12 pm

Re: CSS question

Post by Zyviel »

Thanks for the replies. I guess there is something in my browser settings that is causing the css file to be cached and not checked for changes. I was just curious if there was some kind of code command that would force a browser to check the css file for changes on page load.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS question

Post by Jackolantern »

No, it is completely in the browser and as far as I know, there is nothing you can put in your code to prevent it. It makes sense that way, because the general public will never be seeing your code as it is being actively worked on. When you do a full update on your live site, it should update fine since most browsers are smart enough to pick up a new version of a CSS file. Caching is a cornerstone of the web, and surely saves users hours upon hours of waiting annually.

How did the Ctrl+F5 work for testing?
The indelible lord of tl;dr
Zyviel
Posts: 75
Joined: Tue Jun 08, 2010 8:12 pm

Re: CSS question

Post by Zyviel »

I am at work so not able to try out the Cntrl+F5 suggestion tho I'm sure it will work fine. Jackolantern you mentioned doing a full update to my live site after I have made a change to css, is that some kind of purge or reload I would do using the godaddy interface?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS question

Post by Jackolantern »

Ohhh, I just meant updating the CSS file on your server, either by opening it, editing it and saving or by re-uploading a new file with the same name. You don't have to worry about browser caching on your live site, really. From time to time you may make some design decisions based on effectively utilizing user's browser cache to cut down download times (such as when creating "CSS sprites"), but I can't think of any instance when you would want to try to break the user's cache. They don't stay in their memory for very long, and when a user visits your site, the CSS won't be getting updated every few minutes like when you are in development, so having short-term caching is rarely a problem. The next time the user visits your site when it could be updated, the cache will have fallen out and they will download the new copy automatically. So as long as you can do hard resets in the browser while performing development testing, you should be fine :)
The indelible lord of tl;dr
Post Reply

Return to “General Development”