0

I wonder what happened if I have two web pages on my server using the same script or css files.

If a user opens the first web page and his browser downloads the extern script and css files, then the user goes to my second web page which uses the same script and css files, will the script and css files get downloaded again? If so, how can I avoid this?

Thanks a lot!

David
  • 11
  • 2
  • Sounds like the OP wants to cache files, not prevent caching. – showdev Dec 10 '15 at 21:47
  • Typically they wouldn't be downloaded twice, though it will depend on how your site and server are configured. To confirm for your specific setup, you could use web inspector, of go to http://www.webpagetest.org, run a test for your site and compare the requests for the first and repeat views – David Taiaroa Dec 10 '15 at 21:48
  • What you're asking about is mostly controlled by the client (browser). You can try to suggest to the browser that the content should be cached using http cache control headers, but it is ultimately up to the client to decide whether to download the same files again for another website. – hofan41 Dec 10 '15 at 21:55
  • This is one of the many reasons that many sites are now using SPA (single page app) design patterns. It's pretty efficient to download static resources once and then only need to load in dynamic content as needed. – jered Dec 10 '15 at 22:08

0 Answers0