HTML5 browsers hanging on to cached manifest file - html

I'm using HTML5 appcache and mostly it's working well. However, sometimes, users' browsers (Chrome or Safari) will hold onto the cached manifest file even though I'm positive that the server has a brand new manifest file with a unique version number inside of a comment (like with "# app version 1.0.0.8" or whatever).
In IIS (version 6), the content expiration was set to 1 day, so could that be the problem? I can't seem to reproduce this issue which makes debugging difficult. As a precaution, in IIS I've changed the content expiration to "expire immediately" for the directory that stores the manifest file. Could that explain why some browsers were hanging onto manifest files even when a new version was available?
I also noticed that when a browser was behaving this way, even if I deleted the manifest file on the server, the user's browser would use its own cached copy of the manifest file which isn't supposed to happen if the file is no longer available in my understanding.
Thanks,
Andy

Taken from my answer here : https://stackoverflow.com/a/13282735/727575
Yes, this is the current "correct" behaviour. It has nothing to do with IIS content expiration. This is what happens:
When you just made changes to the manifest file, and you refresh the browser, this is what happens (assuming you're online)
the browser first loads back all the files in the cache
then the browser check online for your manifest file
it detects that the manifest file has changed, it will then proceed to download the new files
however, keep in mind, at this time, you will still be looking at your 'old files' because the browser has loaded the old files before going online to download the 'new files'
if at this point, if you hit refresh again (2nd time), you should get the 'new files'
This is currently the standard behaviour. Some people put some event handlers to prompt the user to do another refresh (after the 1st refresh)
So basically, you need to refresh twice or throw one of the event from 'window.applicationCache' to handle it
To look at an example of using window.applicationCache, go here : http://www.html5rocks.com/en/tutorials/appcache/beginner/
it's under the "Updating the Cache" section.

Related

OBIEE 12C: HTML caching for downloadable file

I've made an analysis in OBIEE which searches for a file in the analyticsRes folder on the server.
The column formula looks like this : ''||"Afdeling"."Afdeling"||''
It downloads the correct file according to the filter you're applying on the dashboard. This works perfectly fine, except for browser cache.
We found out that the browser caches the file behind this link, so when a new one is put on the server, the old one still gets downloaded.
Can I disable browser cache for this analysis only OR for the whole dashboard (is this a good idea?) so that users will always download the newest version of the file?
I've tried adapting the instanceconfig.xml file according to this:
<ServerInstance>
<Cache>
<CatalogXml>
<!-- Remove from the cache everything older than N minutes -->
<MaxAgeMinutes>240</MaxAgeMinutes>
<MaxLastAccessedSeconds>14400</MaxLastAccessedSeconds> </CatalogXml>
</Cache> </ServerInstance>
But this isn't the cache used for my issue.
I expect the analysis to be able to always look on the server for the file, but now it caches the file for a long time. It would be also okay if the cache would expire after 24h.
Thanks!
No. You have zero influence on browser cache from inside OBIEE. The cache above is OBIPS cache, not browser cache.

Issue with the cache manifest "prefer-online" setting

When setting the prefer-online setting I expect the browser to request the page at every refresh of the browser, but it is not the case.
Here is my manifest :
CACHE MANIFEST
SETTINGS:
prefer-online
NETWORK:
*
Yet when I refresh the browser it only requests the manifest to the server. It only requests the page when I update the manifest ...
And there is no headers (expires or max-age) set on the page.
(tested on chrome & firefox)
NB: When updating the manifest, the browser re downloads the assets, but still displays the old version ... It is only on the next load that the browser uses the new assets. Why ?
I don't see what the AppCache manifest is for, since you want to bypass the cache and just use the network. Keep in mind that the regular caching might still apply, regardless of the AppCache manifest, so check the Expires, Last-Modified and similar headers.
As for your question:
NB: When updating the manifest, the browser re downloads the assets, but still displays the old version ... It is only on the next load that the browser uses the new assets. Why ?
This is because the user agent will immediately use the latest cached version of your assets, then start checking the linked resources listed in the manifest for updates. When the user agent detects that the manifest has changed, and thus it has to check for updates, it will fire a checking event.
When the update checking process has finished (and it might take a long time, if you have lots of resources) it will fire an updateready event. Only the resources fetched after this event will be the fresh new ones (that's why it's usually adviceable to use window.applicationCache.swapCache() to tell the browser to swap the old cache for the new for the next page load, or simply reload the page and be done with it).
You will find more detailed explanations about these topics here: http://www.html5rocks.com/en/tutorials/appcache/beginner/

HTML5 App Cache: Manifest ist updated but files are taken from appcache one more time

I have a cache manifest with a comment in it
# Version 3.2
in order to update all the App I simply change the Version number. It works, but:
When I update the manifest, everything is updated correctly (new cache is filled) but the actual files are taken ONE more time from the (old) cache. when I reload twice everything is updated. Is this behaviour correct? Using chrome 21.
Thanks
Yes, this is the current "correct" behaviour. This is what happens:
When you just made changes to the manifest file, and you refresh the browser, this is what happens (assuming you're online)
the browser first loads back all the files in the cache
then the browser check online for your manifest file
it detects that the manifest file has changed, it will then proceed to download the new files
however, keep in mind, at this time, you will still be looking at your 'old files' because the browser has loaded the old files before going online to download the 'new files'
if at this point, if you hit refresh again (2nd time), you should get the 'new files'
This is currently the standard behaviour. Some people put some event handlers to prompt the user to do another refresh (after the 1st refresh)
Personally, I think the browser should be responsible to alert the user to make another refresh after finish downloading the new files, but right now, most people put in event handlers from the "window.applicationCache" to fire events to help manage this.
To look at an example of using window.applicationCache, go here : http://www.html5rocks.com/en/tutorials/appcache/beginner/
it's under the "Updating the Cache" section.
It is possible to instantly swap the cache as described here:
function updateSite(event) {
window.applicationCache.swapCache();
}
window.applicationCache.addEventListener('updateready', updateSite, false);

chrome in offline mode/open cached site?

I have a special kiosk-solution with chrome where I need chrome to upon application start, load the start-url from cache, not try to fetch it online.
The reason is that this is, like I said, a kiosk-mode presentation, is is a screen standing in the public that reboots every night, and if the reboot happens while the ISP has downtime on the internet connection, chrome will only show an error page.
If I can get it to load the cached version of the page though, instead of trying to fetch it online, then the last valid version of the page will show, and through some nifty ajax-workings of mine ;) it will automatically update after a while. If THAT update fails, the currently displayed version of the page will remain until a subsequent update succeeds.
See my problem?
In a browser like firefox I could do it by starting the browser in off-line mode and after page load switch it to online-mode. Only FF doesn't work for me in the particulat project, and Chrome doesn't seem to have an off-line mode?
You could use HTML5 Offline Web Applications to accomplish that. It's probably very easy to set up in your case, just add a file like the following to your app's directory:
CACHE MANIFEST
index.html
help.html
style/default.css
images/logo.png
images/backgound.png
NETWORK:
server.cgi
This manifest should contain all the files you'll need to display some useful information and later grab current content via AJAX. There's also a NETWORK section, where you have to specify things that should not be cached (ie the script that delivers your Updates via AJAX).
You can load the manifest file by adding a manifest attribute to your tag (cache-manifest is the name of the file above):
<html manifest="cache-manifest">
Make sure your server delivers the cache manifest with a MIME-type of
text/cache-manifest MIME
Type or copy-paste the below flag setting into the chrome address bar.
chrome://flags/#enable-offline-mode
scroll down to enable offline stale mode.
Restart your browser.
If an offline version of the page is available in the system cache it will load up when you are not connected.

HTML5 offline strange behaviour

I am having a problem with a web app that I'm working on and I have posted a question here which is a bit vague and probably not very helpful. I have decided to create a really basic site and build it up to be like the main app and see where it breaks. I have done this and got stuck straight away with the offline caching.
This is a basic 3 page static website hosted locally in IIS 7.5. I created the folder c:\inetpub\wwwroot\ManifestTesting, added it to IIS as a web application and added a new MIME type of text/cache-manifest for the .appcache extension. I am also using FireFox 9.0 for testing as this has an offline mode feature.
I created 3 html pages and added them to the ManifestTesting folder:
index.htm - this page contains 2 links to page1.htm and page2.htm
page1.htm - just contains a header that says page 1
page2.htm - just contains a header that says page 2
So now if I browse to http://localhost/manifesttesting if get the index page and can navigate to the 2 pages.
I then created a file called manifest.appcache and added it to the ManifestTesting folder:
CACHE MANIFEST
CACHE:
index.htm
page1.htm
page2.htm
and added the reference to the manifest file in the index.htm:
<html manifest="manifest.appcache">
So if I clear all history and browse to the index.htm, FireFox asks if I want to allow the website to store data for offline use. I click allow, switch the browser to offline mode then attempt to navigate to page1.htm which works fine! So all is good so far.
Now for the bit that I don't understand. I then created a new folder in the ManifestTesting folder called 'pages' and moved page1 and page2 into it. I updated the links in the index to reference the new location and if I browse the website without the manifest reference, it all works fine just as before. I then re-reference the manifest file in the index and update the manifest to be like:
CACHE MANIFEST
CACHE:
index.htm
pages/page1.htm
pages/page2.htm
I then clear history, refresh, firefox asks to allow the website to store offline data, enable offline mode and then attempt to navigate to page1 - it doesn't work! FireFox tells me it's in offline mode and can't browse the web!
What am I doing wrong?
There could be a few possibilities here :
1) Can you try putting in "/pages/page1.htm" instead of "pages/page1.htm"
2) also make sure that all the link and what you type on the browser is Case-Sensitive. ('pages/page1.htm' is not the same as 'pages/Page1.htm')
3) you mentioned that you cleared the history... if you're doing it this way for testing, you need to be clearing the physical files cache too, not just the history.
4) this is probably the most likely cause : when you made changes to the manifest file, and you refresh the browser, this is what happens (assuming you're online)
the browser first loads back all the files in the cache
then the browser check online for your manifest file
it detects that the manifest file has changed, it will then proceed to download the new files
however, at this time, you will still be looking at your 'old files' because the browser has loaded the old files before going online to download the 'new files'
if at this point, if you hit refresh
again (2nd time), you should get the 'new files' (and you would be able to go to the page1 and page2 after going offline
This is currently the standard behaviour. Some people put some event handlers to prompt the user to do another refresh (after the 1st refresh)