It seems Map "remembers" file it was originally loaded with. Meaning if i change file content, Map still loads with an old one. I used to workaround this issue by changing file name every time i load.
Not sure if any new solutions to the issue were introduced recently.
Thank you
4 Answers, 1 is accepted
If you are referring to the loading of a GeoJSON file - this is probably a static file under the web application and it is IIS that performs the caching, RadMap merely does a request for the file and it does not have control over what the server will return. If changing file names or fixing the caching on the server is not an option, you can consider creating a handler that will be sure to return the correct data.
If you are referring to the images for the map tiles - if the map tile service provided is implemented with caching in mind, it is likely that the browser will cache the images, and that would be the expected behavior. It is, however, outside the area of influence of RadMap, as it only consumes the service and creates the <img> elements in the DOM with the appropriate src attrbiute.
Regards,
Marin Bratanov
Progress Telerik
Hi Marin,
I do refer to GeoJSON file with "new" content and "old" name.
Can you please elaborate on two options you mentioned:
1. fixing the caching on the server
2. creating a handler that will be sure to return the correct data
Thank you for the help
David
The following thread shows one way to remove a file from caching: https://stackoverflow.com/questions/3929284/how-do-i-disable-caching-of-an-individual-file-in-iis-7-using-weserver-config-se. You would need to monitor the network response to see what the server returns in order to ensure it is always correct.
<
configuration
>
<
location
path
=
"path/to/the/file"
>
<
system.webServer
>
<
staticContent
>
<
clientCache
cacheControlMode
=
"DisableCache"
/>
</
staticContent
>
</
system.webServer
>
</
location
>
</
configuration
>
---
On a handler - this can be a generic handler that will produce the same output as the geojson file, but it will let you execute code so you can ensure the correct content. It is, basically, a code version of the declarative approach above, because it lets you set your own HTTP headers, including caching headers.
If we take the shapes layer demo, you can do something like the following (which is, of course, really basic, but I hope it serves to show how you can produce the same content from a handler of your own design) and you can, of course, pass querystring arguments to the handler.
<
telerik:RadClientDataSource
runat
=
"server"
ID
=
"RadClientDataSource1"
>
<
DataSource
>
<
WebServiceDataSourceSettings
ServiceType
=
"GeoJSON"
>
<
Select
Url
=
"Content/handler.ashx"
DataType
=
"JSON"
/>
</
WebServiceDataSourceSettings
>
</
DataSource
>
</
telerik:RadClientDataSource
>
<%@ WebHandler Language=
"C#"
Class=
"Handler"
%>
using
System;
using
System.Web;
public
class
Handler : IHttpHandler {
public
void
ProcessRequest (HttpContext context) {
context.Response.AddHeader(
"Content-Type"
,
"application/json; charset=utf-8"
);
context.Response.AddHeader(
"Cache-Control"
,
"no-cache"
);
context.Response.WriteFile(
"~/map/examples/functionality/shapes-layer/content/countries.json"
);
}
public
bool
IsReusable {
get
{
return
false
;
}
}
}
Regards,
Marin Bratanov
Progress Telerik
I'll check it out
Thank you very much