This is a migrated thread and some comments may be shown as answers.

Map caching file

4 Answers 70 Views
Map
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
Veteran
David asked on 17 Sep 2018, 07:20 PM

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

Sort by
0
Marin Bratanov
Telerik team
answered on 18 Sep 2018, 10:26 AM
Hello David,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 18 Sep 2018, 12:41 PM

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

0
Marin Bratanov
Telerik team
answered on 18 Sep 2018, 01:00 PM
Hi 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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 18 Sep 2018, 06:56 PM

I'll check it out

Thank you very much

Tags
Map
Asked by
David
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Marin Bratanov
Telerik team
David
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or