I'm using the JavaScript version of ag-grid to display data on my page. When I update data on a different page and come back to this one, it still shows the cached data from before. If I hit ctrl+F5 it will then refresh. Is there a way to either get it to not cache anything or to refresh on page load? Seems like a simple setting that I'm not seeing.
Update: So I'm not sure if it has anything to do with the cache. It seems like it will refresh that data under circumstances. If I have the dev tools open (Internet Explorer 11), then it will refresh the data with no problem. Seems like a strange thing, not sure if it's browser related or not.
Update 2: It's turns out that it wasn't ag-grid but the way I was querying the data. If you are using jQuery.ajax make sure the cache is setup properly ><.
What caching (HTTP) headers is your data source returning?
You want it to be returning certain headers that tell the browser that the response should not be cached.
For example: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Examples
Look up how to set caching settings with your web server, etc.
Related
The application I'm working on right now contains lots of ng-include directive and I hate to reload the whole application just to see an HTML update.
I've tried Replaying the XHR manually using the Network and it gets back the updated HTML View but definitely, it doesn't get reflected in the DOM.
What I am searching for is a way that all the HTML views get fetched again without me hitting the reload button.
It can be a browser extension or a code snippet (which I'll turn into a browser extension to be used for others) or any other sane way.
Check disable cache checkbox on network page and then try replay XHR. I can't see why you don't want to reload the whole page but whatever.
I would like to do something similiar to opening the developer tools in chrome and checking disable cache and then reload the page.
I can't modify the urls in any way (eg. appending a timestamp in the query) as this will work once, but next time I reload the page normally, the resources will load from the old url without the timestamp and be the old cached version.
I only need support for chrome and I don't have access to the server.
Basically I need the resource files to be update in the chrome cache, without altering the url.
referring from this topic: Prevent browser caching of jQuery AJAX call result
As you are able to editing the server-side script to setting no cache header, it is hard to handler it perfectly on IE. The only way can do for client side is unfortunately adding timestamp on end of the query string.
In Chrome reloading all page resources regardless cache can be forced by long pressing Refresh button while developer tools is open
I version all of my client side JS files like "/js/myfile.js?v=3903948" so that my clients don't need to clear their browser cache to ensure they get the updated files. But every time I push an update, without fail, at least one person runs into a problem where they are running the old version and get some kind of error. I used to think that this was just them having already been on the page during the release and just needing to reload the browser, but this happened to me today when I was definitely not previously on the page. I browsed to the live site and was running the old code. I needed to do a browser refresh on that page to get the new file.
What can cause this?
PS I was using Chrome on Win7, but I have seen clients report this before on all different browsers.
If your main web page can also be cached, then the old version of that page can be requesting the old version of the JS file. JS file versioning works best if the page that actually refers to the JS file cannot be cached or has very short caching time.
I agree with jfriend00 about the webpage itself being cashed and thus requesting the old javascript version.
To prevent this, you can have the javascript file loaded by an ajax (Post) request, either requesting the server what is the accurate(latest) version number to download, or requesting the javascript itself and inserting it, e.g. in the head of the page.
Edit: see for example here
I make a quick AJAX request to the server for the version it expects them to have, then force them to refresh the page if the client's script is old.
Seems that proxy or some load balancer is serving old content instead of new. Also check IIS/webserver settings how are these files cached/expired.
You can check what is going on on the wire with tools like Fiddler.
I have a CGI application written in C. When I POST (delete data) to the cgi app from the html form, the action is correctly executed on the server but the page does not refresh after the POST. It does flicker, but displays the non-updated page. I then have to hit the browsers refresh to see the correct updated html page (showing data has been removed).
Is this the web server? Javascript? or just a browser setting? (I am using GoAhead web server, cgi app in C, javascript, html and Fire Fox.)
Any help is appreciated.
It's your browser cache that is playing tricks on you.
Check the HTTP headers you get when GETting (or POSTing) the page to see if there are anything about cache, if there is it's your webserver that is causing the cache otherwise it's the browser. Try with a different browser, or make the webserver send the page with a negative expiration date.
Are you sure you're returning an updated page in response to the POST?
In order to be sure what is happening, you need to sniff the local network (using Wireshark).
Wrieshark shows you the traffic and also can filter a specific stream.
After you capture you can understand what exactly was sent to the server and what was the respond.
If you are using Firefox you need to install the Firebug plugin and it will show you if your pages are being cached or being retrieved from the server correctly in the "net" panel.
We've identified that full browser caches are the cause of a problem on our extranet. It only affects a small number of our users, but we'd like to alert them to the problem and give them some guidance on how to fix the problem for themselves.
We'd like to use a similar system to the one which GMail uses. When it detects that your browser's cache is full is not behaving as it should, it shows a warning message telling users that their cache is full and that it may cause problems with GMail, along with a link to a Gmail Help page on clearing your browser's cache.
Does anyone know if there any resources out there, or examples of how to use JavaScript to detect that the browser's cache is full behaving badly?
Thanks.
Clarification: What we're actually trying to detect, I suppose, is not whether or not the cache is full, but rather whether a script, which we have configured server-side to be stored in the cache, is being re-requested from the server - in such a way that the browser is behaving strangely, or as if its cache is not behaving as it should.
Further Clarification: Thank you all for the updates on caching. Our scripts are being sent with the correct headers, and we're only seeing this problem in IE6 and IE7 - Mozilla and WebKit browsers seem to be unaffected - but I'm still not sure on how exactly we'd go about using JavaScript and/or XmlHttpRequest to check to see whether or not an object was retrieved from the cache, thus letting us check whether the cache is behaving badly.
The browser's cache will not cause problems if it is full... with a few minor notes.
If the browser cache is full, the browser simply has to download fresh content vs. pulling it from its local cache. (e.g. is slower)
If the browser cache contains invalid data (e.g. an old copy of a JavaScript file) then yes, you may encounter issues. (not because the cache is full, but because you didn't serve up a fresh file for the user (Google for: expires headers and how to alter the URL path to your files when you make script changes to ensure you "break" the cache))
In Internet Explorer, when you push a download file (e.g. an Excel spreadsheet) to the user it must go into the cache to work (an IE bug) - I'm not sure if the file is bigger than the users' total cache, if that causes issues with the file being stored, and therefore loaded (Stackers pls feel free to confirm if this one way or another)
Update:
Based on your clarification, you need to ensure that any script you send to the client is appropriately cached... which means:
Change the URL to your scripts when you want a new version to be downloaded (e.g.)
http://example.com/scripts/latestThing.js?ver=3425
where the "ver" is pulled from your versioning system to ensure you always force the browser to download a fresh copy any time you change your script.
Once you are sure that the URL changes, you can send cache headers that tell the browser to cache the files for a very long time (e.g. your JS Library files (e.g. jQuery) likely don't change every hour, day, week or even month)
This will probably not work as is. But its just an idea:
var img = new Image();
(new Image).src = "imageWithFarFutures.png";
window.onload = function(){
document.getElementById("someIframe").src = "imageWithFarFutures.png";
// NOW if the server DOES get a FRESH request for "imageWithFarFutures.png"
// wouldn't it mean that the browser has kicked it out of its cache?
};
Consider sending a header to have your application never cache your content and to have it expire immediately.