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
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.
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 (http://extreme-macro.co.uk/forumstest/index.php) - is the forumname small or large?
Thanks
to me i would say that is large
(http://imagizer.imageshack.us/v2/865x64q90/538/HyNldT.png)
given i have never been to that site before, there is no cache for css on my browser.
Thanks, appreciated. Yes it's what's supposed to show :)
-Johan
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/
I'm huge on caching, I love it. All those lovely 304s in the log files. I just didn't think this was caching :).
.htaccess -
# NEVER CACHE
<FilesMatch "\.(txt|htm|html|php|css)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>
that would be server side, the op is asking about browser caching of css.
That works ;) Setting the headers for "no cache" through htaccess instructs the browser to not cache the mentioned files ;)
interesting as the browser does not really "read" the .htaccess file on a page load.
Yeah, but Apache does something with it, which the browser understands ;)
Don't ask me the specifics, though :P