3

I have a requirement where I need only the js and css files to be cached. Other files or JSON data should not be cached.

How can I force the browser to download the js and css files only from the cache, not other data like JSON returned from AJAX calls, etc..

I am looking for client-side solutions where possible.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
user3263194
  • 453
  • 6
  • 20
  • Use MVC [bundling](http://www.asp.net/mvc/overview/performance/bundling-and-minification) –  May 14 '15 at 09:36
  • I'm using mvc bundling for caching. But I dont want json data in request headers of ajax call to be cached as it contains sensitive data. I want only the js and css files to be cached. – user3263194 May 14 '15 at 09:38
  • http://stackoverflow.com/questions/3644748/cache-css-and-js-files check this – Amit Soni May 14 '15 at 09:39
  • possible duplicate of http://stackoverflow.com/questions/15041603/how-to-prevent-the-browser-from-caching-a-json-file – Anil May 14 '15 at 09:40
  • http://stackoverflow.com/questions/2105481/how-to-cache-css-images-and-js or this – Amit Soni May 14 '15 at 09:41
  • My question here is different. I'm using client caching and my files are getting cached. But I don't want the ajax request header to be cached. – user3263194 May 14 '15 at 09:59
  • @user3263194 if JSON is only ever returned in POST requests, then you won't have a problem as this is not cached by the client. If it is returned in response to a GET request - assuming you are using JQUERY to make an AJAX request for it, there is a cache:false option - http://api.jquery.com/jquery.ajax/ – Carl May 14 '15 at 10:38
  • I've updated the question to improve the capitalization and grammar, and removed extra text like "Please" and "Thank you". Stack Overflow is a technical site, not a forum, so we don't need pleasantries. You may wish to further differentiate your question from the existing questions pointed out in other comments. – Heretic Monkey May 14 '15 at 21:21

0 Answers0