Select to view content in your preferred language

exportwebmap - how to make file name unique so resultant PDF is not cached by browser

1297
6
Jump to solution
08-26-2013 03:55 PM
SebastianRoberts
Frequent Contributor
Hello,
  We are using the export web map service to provide for the creation of PDFs in our web applications.  Usually this works nicely.  However, ArcGIS server seems to reuse file names after clearing the output directory.  We have had users creates more than a handful of PDFs, and because their browser has cached the previous PDFs, instead of fetching a new PDF, it shows an older cached PDF.  Is there a way of making the file names unique over a certain period of time?  The file names have a nice long string which I assume is unique to my server/service, but the last three digits are the only part that changes for each PDF, and they seem to get reused far too often.  For example : _ags_8d9ea50233b940c081faca4a2a81af629.pdf.  The only part of the file name that changes for this service is the last three digits "629", and they only go from 621 to 629, and then they get reused.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
OttarViken_Valvåg
Regular Contributor
Actually, I found an easy workaround on the client, for those who have control over what it does. I add a timestamp to the url so that it's always unique. Now the browser won't used the cached file even though the filename is the same, since I added a unique query parameter.

this.executePrint({     template: "MAP_ONLY",     format: format,     preserveScale: false,     showAttribution: false,     exportOptions: exportOptions }).then(lang.hitch(this, function (result) {     var url = result.url + "?ts=" + new Date().getTime(); // Add timestamp to avoid browser caching     window.open(url); })

View solution in original post

0 Kudos
6 Replies
IsmaelChivite
Esri Notable Contributor
Hi,

you may want to try controlling the clean up time of your output directory. By default the output folder is cleaned up after 10 minutes which may be too often in your case. In ArcGIS Server Manager, log as an administrator, go to 'site', then 'directories' and edit the output folder clean up time increasing the time.

Ismael
0 Kudos
TanuHoque
Esri Regular Contributor
SRRoberts,
The problem got fixed in 10.1 SP1.

While you are waiting on updating to SP1, Ismael's suggestion is perfectly a valid workaround.
0 Kudos
TanuHoque
Esri Regular Contributor
Sebastian,

My apology, it got fixed in 10.2.
http://support.esri.com/en/bugs/nimbus/role/beta10_1/TklNMDkwMjA0

Tanu
0 Kudos
OttarViken_Valvåg
Regular Contributor
It would be nice to have a better workaround for this in 10.1. Increasing the cleanup time of the output directory won't really help.

Is it possible to configure http headers returned by arcgis server to tell the browsers not to cache the output images?
0 Kudos
OttarViken_Valvåg
Regular Contributor
Actually, I found an easy workaround on the client, for those who have control over what it does. I add a timestamp to the url so that it's always unique. Now the browser won't used the cached file even though the filename is the same, since I added a unique query parameter.

this.executePrint({     template: "MAP_ONLY",     format: format,     preserveScale: false,     showAttribution: false,     exportOptions: exportOptions }).then(lang.hitch(this, function (result) {     var url = result.url + "?ts=" + new Date().getTime(); // Add timestamp to avoid browser caching     window.open(url); })
0 Kudos
SebastianRoberts
Frequent Contributor
Ottar,
  Thanks, that works perfectly!  For anyone using the tax parcel viewer, you can change the window.open line in the submitPrintRequest function in the utils.js file to:
window.open(data.results[0].value.url +  "?ts=" + new Date().getTime() );


If you are using the print widget in Flex, if you can edit and recompile the  print widget, then change the printTask_executeCompleteHandler function  in the  ExportWebMapForm.mxml as follows:

var date:Date = new Date();
var dateString:String = "" + date.fullYear + (date.month+1) +  date.date + date.hours +  date.minutes + date.seconds
navigateToURL(new URLRequest(dataFile.url + "?ts=" + dateString ));