The RESTful angular application in Microsoft Edge Browser Caching
source link: https://www.codesd.com/item/the-restful-angular-application-in-microsoft-edge-browser-caching.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The RESTful angular application in Microsoft Edge Browser Caching
I'm developing a Webapp that uses Angular.js which server by a RESTful API. During the development phase I use my preferred browser which is Chrome, but I just ran some tests in Edge and made some interesting discoveries.
I noticed that the result of a call to the RESTful server was seemingly returning incorrect data. Upon closer inspection I realised that this was due to the Edge browser loading the results from Cache rather than making the call to get the latest and correct results. What's more I realised that I can remove whole functions from my Angular app file and Edge doesn't seem to complain!
The angular function in question:
$http.get(frontbaseurl+'/users/auth_user.json').then(function(response){})
I've read a few responses to questions on SO that suggest various ways to force Edge to not cache results (for example adding a data stamp to the get url), but it sounds hacky and in my case it didn't work anyway.
I can't quite believe my findings. The coder in me wants to shrug my shoulders and put this down to yet another catastrophe from MS, but I can't ignore the fact some unfortunate individuals may have no other choice and could experience errors if they use my web app.
Anyone else experienced this?
As a web developer, I really appreciate that browsers put heavy cache to avoid unnecessary requests to my server and help my users to have a faster, and better, experience.
There are many techniques to request the browser to stop caching, but please, don't do that! Caching is very helpful and there are smart ways to prevent the browser to use old content.
I've read a few responses to questions on SO that suggest various ways to force Edge to not cache results (for example adding a data stamp to the get url), but it sounds hacky and in my case it didn't work anyway.
I believe that you missed the point here. You don't add the a data stamp to the get url. You need to add it to the file url.
Wrong:
$http.get(frontbaseurl+'/users/auth_user.json?v=20160510').then(function(response){})
Right:
<script src="/path/to/services.min.js?v=20160510"></script>
Adding the querystring to the file name should be part of your build action.
Recommend
-
26
The performance of our websites is an essential factor to consider. One of the ways to improve it is to cache our resources, and there are many ways to implement it. In this article, we define what caching is and go throug...
-
14
Web Performance in a Nutshell: HTTP/2, CDNs and Browser CachingWeb Performance in a Nutshell: HTTP/2, CDNs and Browser CachingSuccessful websites need to be fast, scalable and secure. In this a...
-
9
Tutorial How To Implement Browser Caching with Nginx's header Module on CentOS 8 Nginx
-
4
Tutorial How To Implement Browser Caching with Nginx's header Module on Ubuntu 20.04 Nginx ...
-
1
Have you ever noticed that when you load a web page for the very first time, it takes a little bit longer than the second, third, etc. times that you visit that page? That’s not just coincidence my friend, that’s browser caching, and today we...
-
1
nico_lrx Posted on Oct 25
-
2
Browser getting new capabilities starting with version 102
-
2
Disk caching in Microsoft Edge Written By published July 27, 202...
-
1
Caching Dynamic Content at the EdgePhoto by
-
4
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK