browser cache

3874
35
Jump to solution
05-08-2012 07:38 AM
EricGardecki
Occasional Contributor
It seems like I often have to clear my browser's cache after updating some things with my web app or else the changes do not show.  Clearing the REST cache doesn't take care of everything.  I think the average user would not think to clear their cache let alone even know how and they would not see changes/fixes.  Is there a way to force it on load somehow?  If not, Any ideas on how to get people to understand that it may be necessary?  I doubt that a snippet in a help page would be enough....plus when would they even know that a change has been made and they need to clear it?

thanks!
Tags (2)
0 Kudos
35 Replies
MattiasEkström
Occasional Contributor III
Eric, I reacently noticed that this fix doesn't apply to the PopUpConfig-files too. It was a little bit more tricky to fix than I first thought, I will try to solve it and post back here when/if I'm able to solve it...
As it is now it applies to config-files, both main-configs and widget configs and all widget swf files. For the index.swf I think you have to add a timestamp to the index.html file if you haven't already done that.

Concerning the .swz-files I don't think there is any differens between them so you can just take the index.swf. But I'm not 100% sure...
0 Kudos
EricGardecki
Occasional Contributor
I haven't done anything to the index.html so I revisited that thread.  So I should change this:

swfobject.embedSWF(
                "index.swf", "flashContent",
                "100%", "100%",
                swfVersionStr, xiSwfUrlStr,
                flashvars, params, attributes);


to this?

swfobject.embedSWF(
                "${swf}.swf?ts=" + new Date().getTime(),
                "100%", "100%",
                swfVersionStr, xiSwfUrlStr,
                flashvars, params, attributes);


as for the new .swz files, apparently they are required to go along with the new index.swf because it didn't work without them.

I did notice that this cache fix did not work on the "MySplash" widget, but maybe the change above will take care of that.

thanks
0 Kudos
MattiasEkström
Occasional Contributor III
Eric, yes that change will make sure that the main application index.swf is not loaded from the browser cache.
Due to some datatype problems with the PopUpConfig URLs in ConfigManager it is easier to do that fix in the MapManager.mxml
Look for the line:
var popUpConfigURL:String = arrLayerPopUp.popUpConfig;

It should be around line nr 1017, and replace it with:
var popUpConfigURL:String = String(arrLayerPopUp.popUpConfig) + "?ts=" + new Date().getTime();

That should make sure that PopUpConfigs doesn't load from browser cache...
0 Kudos
EricGardecki
Occasional Contributor
ok I made that change in the MapManager.mxml and it seems to work perfectly.  Thanks!

As for the index.html, when I make that change the application doesn't load.  I get a message about it requiring flash 10.2.  I am up-to-date.   Are you sure my code above is exactly right?
0 Kudos
MattiasEkström
Occasional Contributor III
sorry, your code above was a mix of what it should be in the index.template.html and the index.html.
In the index.html it should be:
swfobject.embedSWF(              "index.swf?ts=" + new Date().getTime(), "flashContent",                 "100%", "100%",                 swfVersionStr, xiSwfUrlStr,                 flashvars, params, attributes);
0 Kudos
EricGardecki
Occasional Contributor
that did it.  thanks again.
0 Kudos
DanielJohns
Occasional Contributor
Hi, I'm using 2.5 and was trying to achieve the same thing (disable the swf caching). I've attempted the recommendations above, but it's still loading the old version from cache (using IE9).

I've tried the MapManager.mxml mod and also the Index-template mod (also verified the build) with no success.

I'm using the eSearch tool as well as a splash page (not sure if that would make a difference).

my Index-template.html has the following mod.

swfobject.embedSWF(
             "index.swf?ts=" + new Date().getTime(), "flashContent",
                "100%", "100%",
                swfVersionStr, xiSwfUrlStr,
                flashvars, params, attributes);

Flash also ignored the following (for those who may come across other post).

  <meta http-equiv="Cache-control" content="no-cache" />
  <meta http-equiv="Cache-control" content="no-store" />
  <meta http-equiv="Cache-control" content="must-revalidate" />
  <meta http-equiv="Cache-control" content="max-age=-1" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Pragma" content="no-store" />
  <meta http-equiv="Expires" content="-1" />


Thank you for any recommendations to resolve the issue 😉

Daniel
0 Kudos
EricGardecki
Occasional Contributor
Have you applied the time stamps to the multiple lines in the ConfigManager.as?
0 Kudos
DanielJohns
Occasional Contributor
I'm actually doing that right now. I found another forum post that mentions it.

http://forums.arcgis.com/threads/16664-Preventing-client-side-caching-of-the-Flex-Viewer?p=105311&vi...

I have 2.5 (Robert provided the one for 2.3.1) so I have to search and replace, but it this works I will reply.

Thank you
0 Kudos
DanielJohns
Occasional Contributor
Okay, so I've modified just the ConfigManger.as. Completed the 'Export Build Release' and moved it to the production server.

I enter the url http://server/flex and nothing changes (still pulling from cache). Should I be expecting to see server/flex/index.swf?...

Update: Well, I think it's finally working.

I took the zip from http://forums.arcgis.com/threads/57121-browser-cache?p=197488&viewfull=1#post197488
and used the ConfigManager.as, the only difference from ours was the double ;; on a couple of lines (I used one).

I also added swfobject.embedSWF(
                "${swf}.swf?ts=" + new Date().getTime(), "flashContent",
                "${width}", "${height}",
                swfVersionStr, xiSwfUrlStr,
                flashvars, params, attributes);

back to the Index.html and it loaded a fresh page 😄

Now for more testing. Thank you!
0 Kudos