question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an option to avoid cache effect

See original GitHub issue

As 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:closed
  • Created 7 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cleliofscommented, Jun 18, 2021

In Chrome, there is an option to “disable” browser cache: image

0reactions
DenisKnoepflecommented, Oct 22, 2020

I am using $ref tag to embed the yaml schema file. It loads it for the first time , but doesn’t reflect any subsequent updates to that remote reference.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found