I have a very simple site and all the CSS for it is written in one file, so whenever any page is requested the CSS file is loaded. So I was wondering if there is someway, that I can tell the browser to use the same file it loaded a second ago instead of requesting it again.
Asked
Active
Viewed 118 times
1
-
2Usually CSS is loaded into the clients browser cache ... so it only loads the first time unless he clears his browser history – JonoJames Jul 06 '22 at 05:26
-
Look at this question [#1341089](https://stackoverflow.com/questions/1341089/is-there-a-meta-tag-to-turn-off-caching-in-all-browsers). – Jonas Vieira de Souza Jul 06 '22 at 05:31
1 Answers
1
I assume you have the css loaded externally then? I don't believe there is a way to natively do that unfortunately. But, if you're proficient in javascript, I suppose you could save all of the css file as a string using the localStorage property in the browser. Then request the data you want loaded specifically per site.
Local storage persists after the browser is closed, so it would only need to be loaded once!

Jacob Rodriguez
- 68
- 6