Add an option to avoid cache effect
See original GitHub issueAs discussed here: https://github.com/swagger-api/swagger-ui/issues/2203#issuecomment-225065423
I would like to avoid cache effect with Internet Explorer By default, IE will cache json answer and If I do this sequence on a CRUD ReST API I’ve not the expected result
- get items => res A
- post new item => res B
- get items => res C
In my case, res A == res C but a new item is expected as res B is a success (I don’t reproduce on another browser than IE).
@fehguy suggest:
Create a request interceptor and set the headers before the request is sent:
var interceptor = {
requestInterceptor: {
apply: function (requestObj) {
var headers = request.Obj.headers || {};
headers['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
headers['Cache-Control'] = 'no-cache';
headers['Pragma'] = 'no-cache';
return requestObj;
}
}
};
// assign the request interceptor in the UI
new SwaggerClient({
url: 'http://localhost:8000/v2/petstore.json',
requestInterceptor: interceptor.requestInterceptor,
I have not tested this solution but I like it. As it is a common issue, I would like this as an option.
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Cache-Control - HTTP - MDN Web Docs
no -cache allows clients to request the most up-to-date response even if the cache has a fresh response. Browsers usually add no-cache to ......
Read more >Prevent Caching in ASP.NET MVC for specific actions using ...
To ensure that JQuery isn't caching the results, on your ajax methods, put the following: $.ajax({ cache: false //rest of your ajax setup...
Read more >Prevent unnecessary network requests with the HTTP Cache
How can you avoid unnecessary network requests? The browser's HTTP Cache is your first line of defense. It's not necessarily the most ...
Read more >How do I prevent CloudFront from caching certain files? - AWS
4. If you already have a cache behavior for the objects that you don't want CloudFront to cache, then select the cache behavior...
Read more >Disable Caching Setting During Development | Lightning Aura ...
Disable the secure and persistent browser caching setting during development in a sandbox or Developer Edition org to see the effect of any...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In Chrome, there is an option to “disable” browser cache:
I can confirm this. I am experiencing exactly the same issues. Even force-refreshing the browser (CTRL+F5 under Chrome) does not refresh the stale referenced file. The only way to get it refreshed is to wipe out whole browser data cache.