0

I have a js file loaded in cache.

When a html file is loaded in browser it sends a Conditional Requests (found from here) to the server to check if that resource is changed or not.

What I want to do is do not send any request to the server (neither Conditional Requests nor fresh request) when the resource is cached.

Is it possible?

If possible what are the solutions for that?

If not why?

Ashwin
  • 12,081
  • 22
  • 83
  • 117
  • What if they clear the cache? Aside from this, you only have web server configuration at your disposal. You cannot control how the user's browser handles web requests. –  Oct 27 '14 at 13:48
  • @DeeMac - What if they clear the cache? - I have considered this scenario but still I want to achieve what I have mentioned in the question. Rest of your comment is useful to me. – Ashwin Oct 27 '14 at 14:12

1 Answers1

1

Yes, it is certainly possible to tell the browser that your content won't change so it doesn't need to make a request. You should use either the Cache-Control header's max-age parameter, or the Expires header. This prior StackOverflow post discusses the pros and cons of using each.

Community
  • 1
  • 1
Craig S. Anderson
  • 6,966
  • 4
  • 33
  • 46