2

We have multiple pages on a website which require many of the same Javascript and CSS files.

How do we avoid those files being downloaded again if it has already been downloaded by the user browsing some other page?

3 Answers 3

4

If the file is in the same path, the browser should automatically cache it. You may want to explicitly specify the cache expiry time, if possible via your web server or programming environment.

Sign up to request clarification or add additional context in comments.

Comments

3

If you use an HTTP traffic analyzer like Fiddler you should see that requests for JavaScript and CSS resources return an HTTP code 304 (Not Modified). This tells the browser "the version of the resource you have in your cache is the same as the one on the server so you don't need to download it again".

For even better performance you can explicitly set caching headers for these resources.

This caching tutorial has great info.

Comments

0

You should explicitly set caching headers if you want caching. www.fiddler2.com/redir/?id=httpperf

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.