Simple Machines Community Forum

General Community => Scripting Help => Topic started by: roshaoar on May 20, 2015, 05:48:49 AM

Title: css on divs requiring refresh, how to stop?
Post by: roshaoar on May 20, 2015, 05:48:49 AM
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
Title: Re: css on divs requiring refresh, how to stop?
Post by: Illori on May 20, 2015, 05:55:32 AM
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.
Title: Re: css on divs requiring refresh, how to stop?
Post by: roshaoar on May 20, 2015, 06:07:35 AM
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
Title: Re: css on divs requiring refresh, how to stop?
Post by: Illori on May 20, 2015, 06:16:24 AM
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.
Title: Re: css on divs requiring refresh, how to stop?
Post by: roshaoar on May 20, 2015, 06:36:56 AM
Thanks, appreciated. Yes it's what's supposed to show :)

-Johan
Title: Re: css on divs requiring refresh, how to stop?
Post by: margarett on May 20, 2015, 07:57:58 AM
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/
Title: Re: css on divs requiring refresh, how to stop?
Post by: roshaoar on May 20, 2015, 08:07:55 AM
I'm huge on caching, I love it. All those lovely 304s in the log files. I just didn't think this was caching :).
Title: Re: css on divs requiring refresh, how to stop?
Post by: Sir Osis of Liver on May 20, 2015, 12:56:27 PM

.htaccess -



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


Title: Re: css on divs requiring refresh, how to stop?
Post by: Illori on May 20, 2015, 01:04:42 PM
that would be server side, the op is asking about browser caching of css.
Title: Re: css on divs requiring refresh, how to stop?
Post by: margarett on May 20, 2015, 01:51:53 PM
That works ;) Setting the headers for "no cache" through htaccess instructs the browser to not cache the mentioned files ;)
Title: Re: css on divs requiring refresh, how to stop?
Post by: Illori on May 20, 2015, 02:06:12 PM
interesting as the browser does not really "read" the .htaccess file on a page load.
Title: Re: css on divs requiring refresh, how to stop?
Post by: margarett on May 20, 2015, 02:28:39 PM
Yeah, but Apache does something with it, which the browser understands ;)
Don't ask me the specifics, though :P