0

I have a javascript file which internally calls a function to load an xml file.

$(document).ready(function()
 {
    urlVal ="web/help.xml";
  }


The javaxcript is versioned so that the browser always loads it instead of 
caching it
    "./js/help_min.js?ver=${verNumber}"

I am facing an issue where browser downloads the latest js file but has cached help.xml included in js file. is there a way that the browser will always load latest "hepl.xml" rather than caching it.

1 Answers1

1

The proper apporach would be to fix the backend to send headers telling the browser not to cache the data (see i.e. How to control web page caching, across all browsers?). But if you cannot do that, make the request unique each time, i.e.

"./js/help_min.js?ver=${verNumber}&random=${something_random}"

where something_random value of random can be i.e. current time stamp (with millis). That way your request will not match the cache entry enforcing fetch on each request.

PS: you seem to also have design flaw, as by logic using the same ${verNumber} should return the same data, hence caching would be more than welcome to reduce the traffic and speed up loading time.

Marcin Orlowski
  • 67,279
  • 10
  • 112
  • 132