After updating my web app, users need to clear browser cache

After I updated my web app, some of my users (on Firefox) were getting errors on the page and some controls were not working properly. I asked them to clear their cache, and that seemed to fix the problem.

Is there something we can do to prevent the need for this intervention? Is there a better way to anticipate when it will be needed?

Hi Mark,

You can put the following code in the pagesource of the webpage.
It forces the browser to refresh every time it is called.

title

Eric

[quote=134738:@Eric Dirks]Hi Mark,

You can put the following code in the pagesource of the webpage.
It forces the browser to refresh every time it is called.

title

Eric[/quote]
Is there a way to conditionally do this - since I expect this will add a sluggish feel to the page/app load?

My strategy would be to store a cookie after executing this HTML that indicate it has been run for this version of code. Then when I update the app again, I will see that this HTML has not yet been run with that code version.

I don’t know how often you update your software, but i think most of your clients will probably delete cookies on regular basis anyway.
As it is very easy to add to your program, just give it a try. I think that it won’t make a big diffence on performance and you are always sure that old content is refreshed.
If you want to do it conditionally you can set and check a cookie in javascript and act upon the result.
See www.w3scools.com/js/js_cookies.asp how to set and check cookies in Javascript .

I will give it a shot. Thanks.

What version of the IDE are you using?

I have used this with my 2013.4.1 version because pictures didn’t refresh.
Now I am using 2014.2.1 . Has there been some change on this subject ?

There has. We’ve made it so frameworks are marked as being current as of the build date of your app ( so browsers will only download them once per build ) but the functionality wasn’t complete until 2014r2.

[quote=134738:@Eric Dirks]Hi Mark,

You can put the following code in the pagesource of the webpage.
It forces the browser to refresh every time it is called.

title

Eric[/quote]
If you’re going to do this, don’t use a page source. There’s already a head tag and you’ll confuse some browsers. Just put the meta tag in the App.HTMLHeader property.

I did’nt know . I will give it a try.

So I think that means that starting with 2014r2, browsers will automatically refresh (clearing the appropriate cache) when the build date for the webapp has changed - no coding action required on my part. Do I understand that correctly?

What happens is the browser sends a request to the server saying, “I need this file, but I’ve already got one with this date. Is there a newer one?” We compare the date against the build date of the app (the dates are all UTC) and if the app is newer, we send the latest framework files. If not, we return a header that says to use the one it already has.

It’s not an automatic refresh per se, just being a little more intelligent about not delivering assets that the browsers already have up to date copies of.

[quote=134775:@Greg O’Lone]What happens is the browser sends a request to the server saying, “I need this file, but I’ve already got one with this date. Is there a newer one?” We compare the date against the build date of the app (the dates are all UTC) and if the app is newer, we send the latest framework files. If not, we return a header that says to use the one it already has.

It’s not an automatic refresh per se, just being a little more intelligent about not delivering assets that the browsers already have up to date copies of.[/quote]
Got it - thanks.

[quote=134741:@Mark Pastor]Is there a way to conditionally do this - since I expect this will add a sluggish feel to the page/app load?

My strategy would be to store a cookie after executing this HTML that indicate it has been run for this version of code. Then when I update the app again, I will see that this HTML has not yet been run with that code version.[/quote]

Your probably better todo it every time, for use like me who run a cookie cutter app.

@Robert Schofield

Exactly my point. And I think the delay is minimum.

On the other hand, if performance is an issue you could check for the cookie if it is there, you check it and act on it. If its not you always send de refresh code.

There is no code you can send to the browser to force a refresh of the cache… And be very careful with cookies. Make sure you’re not just setting true/false, but something that uniquely identifies the build of the app. Just adding/removing controls to your project can change which frameworks are delivered.

It’s not just about saving time on the browser. Every time your app has to process a request and return a file, it takes precious CPU cycles for your app, making the response slower for any other Sessions in the process.