News:

Wondering if this will always be free?  See why free is better.

Main Menu

css on divs requiring refresh, how to stop?

Started by roshaoar, May 20, 2015, 05:48:49 AM

Previous topic - Next topic

roshaoar

Hi,

Bit of a dippy question but I've noticed that when I style a div with CSS, often it takes a refresh before the CSS takes effect. Maybe this is an IE problem, but what can I do about this to make a refresh unnecessary and have the css on the div show straight away. Is it a case of order in the CSS file?

Many thanks,

-Johan

Illori

browsers cache things, things like css especially. there is nothing you can really do to stop a browser from caching css and requiring a hard refresh to clear that cache.

roshaoar

Is cache the only possible reason? On the new div I created last night, it showed as non css first then got the css on the refresh. What happens when you go here - is the forumname small or large?

Thanks

Illori

to me i would say that is large


given i have never been to that site before, there is no cache for css on my browser.

roshaoar

Thanks, appreciated. Yes it's what's supposed to show :)

-Johan

margarett

You can try some tricks to make the browser not caching these things. Although it should always be a temporary solution because caching saves bandwidth ;)
https://arjunphp.com/prevent-css-javascript-files-cached/
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

roshaoar

I'm huge on caching, I love it. All those lovely 304s in the log files. I just didn't think this was caching :).

Sir Osis of Liver


.htaccess -



# NEVER CACHE
<FilesMatch "\.(txt|htm|html|php|css)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

that would be server side, the op is asking about browser caching of css.

margarett

That works ;) Setting the headers for "no cache" through htaccess instructs the browser to not cache the mentioned files ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Illori

interesting as the browser does not really "read" the .htaccess file on a page load.

margarett

Yeah, but Apache does something with it, which the browser understands ;)
Don't ask me the specifics, though :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: