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

How to inhibit client side caching?

7 Answers 256 Views
Map
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 08 Jun 2010, 07:26 PM
I've successfully implemented a custom tile server map provider using the MapProviderBase abstract class.  Is there a way to turn off the client side caching?  Every time I run my application, I can see the correct tiles loading from the tile server, but they don't overwrite the old tiles stored in the client side cache. 

How to I turn this feature off? 

Thanks!
Chris
CTI

7 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Jun 2010, 10:09 AM
Hello Chris,

When you assign the IsTileCachingEnabled property to "True" for your provider without specification of the cache storage then it automatically enables the file system tile caching.
The MapProviderBase class supports the file system cache, isolated storage and memory cache.
So, if you don't want to save tiles on the client side file system, then you can use the memory cache.
The sample code of using the memory cache is below.
XAML:
<telerik:RadMap
    Name="radMap">
    <telerik:RadMap.Provider>
        <local:CustomOpenStreetMapProvider
            IsTileCachingEnabled="True">
            <local:CustomOpenStreetMapProvider.CacheStorage>
                <telerik:MemoryCache  MemoryMaxSize="100000000" />
            </local:CustomOpenStreetMapProvider.CacheStorage>
        </local:CustomOpenStreetMapProvider>
    </telerik:RadMap.Provider>
</telerik:RadMap>

C#:
public MainWindow()
{
    InitializeComponent();

        this.radMap.Provider = new CustomOpenStreetMapProvider();
    
this.radMap.Provider.CacheStorage = new MemoryCache() { MemoryMaxSize = 100000000L };
    this.radMap.Provider.IsTileCachingEnabled = true;
}

Greetings,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chris
Top achievements
Rank 1
answered on 09 Jun 2010, 05:23 PM
Thanks for the reply Andrey!  Is there any way to clear the file system cache?
0
Andrey
Telerik team
answered on 10 Jun 2010, 09:54 AM
Hi Chris,

If you will still use file system cache, then you can override the OnIsTileCachingEnabledChanged method in your custom map provider.
When you don't specify the cache storage then it automatically enables the file system tile caching with default path. The OnIsTileCachingEnabledChanged method allows getting this path and you can clear this folder.
The sample below clears a cache one time. It creates an empty file as a flag that the folder has been cleared.
<telerik:RadMap
    Name="radMap">
    <telerik:RadMap.Provider>
        <local:CustomOpenStreetMapProvider IsTileCachingEnabled="True" />
    </telerik:RadMap.Provider>
</telerik:RadMap>
protected override void OnIsTileCachingEnabledChanged(bool oldValue, bool newValue)
{
    base.OnIsTileCachingEnabledChanged(oldValue, newValue);

    
var cacheStorage = this.CacheStorage as FileSystemCache;
    if (cacheStorage != null)
    {
        string cachePath = cacheStorage.CachePath;
        string clearedFlagFileName = cachePath + "\\isCleaned";
        if (!File.Exists(clearedFlagFileName))
        {
            Directory.Delete(cachePath, true);
            Directory.CreateDirectory(cachePath);

            
var cleanedFlagFile = File.CreateText(clearedFlagFileName);
            cleanedFlagFile.Close();
        }
    }
}

If you will use memory cache, then you can clear the cache folder using the following way:
<telerik:RadMap
    Name="radMap">
    <telerik:RadMap.Provider>
        <local:CustomOpenStreetMapProvider IsTileCachingEnabled="True">
            <local:CustomOpenStreetMapProvider.CacheStorage>
                <telerik:MemoryCache  MemoryMaxSize="100000000" />
            </local:CustomOpenStreetMapProvider.CacheStorage>
        </local:CustomOpenStreetMapProvider>
    </telerik:RadMap.Provider>
</telerik:RadMap>
protected override void OnIsTileCachingEnabledChanged(bool oldValue, bool newValue)
{
    base.OnIsTileCachingEnabledChanged(oldValue, newValue);

    
string profile = Environment.GetEnvironmentVariable("LOCALAPPDATA") + "\\";
    string cachePath = profile + "TelerikMapCache\\" + this.GetType().Name;
    if (Directory.Exists(cachePath))
    {
        Directory.Delete(cachePath, true);
    }
}

Regards,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Caleb
Top achievements
Rank 1
answered on 25 Mar 2011, 10:03 AM
When entering stock items in stock on IDEALPOS. what happens when you tick inhibit voids after creating a new stock item?
0
Andrey
Telerik team
answered on 29 Mar 2011, 03:03 PM
Hello Caleb,

Can you supply some additional details on the issue which you are facing with the RadMap control, or the functionality which you are trying to achieve?

Best wishes,
Andrey Murzov
the Telerik team
0
Mirko
Top achievements
Rank 1
answered on 19 Aug 2013, 09:17 AM
Hi,

we have written a own TileService which returns the images of the current configurated provider. But now we have the problem that the client has cached the images and we don´t see the new images.


I have test some workaround I have test some solutions from your post. I´m have set the IsTileCachingEnabled to false or change the cache manager to telerik:MemoryCache. But everytime we get some new pictures and some old pictures (I´m thinking cached items). 

What could I do that we have no cache or only cache for the runtime? 

We are using the Release 2013.1 and in silverlight code code works fine. 

Thanks
0
Andrey
Telerik team
answered on 22 Aug 2013, 08:49 AM
Hello Mirko,

There is a difference between the Silverlight and the WPF version of RadMap. The Silverlight version is based on the standard Silverlight MultiScaleImage and MultiScaleTileSource controls. Unfortunately, there are no such controls in WPF, so we have created our own implementation of these controls for WPF.
The WPF version allows to set .Net request cache level for downloading of tiles. The TiledProvider class contains an additional RequestCacheLevel property. By default its value is System.Net.Cache.RequestCacheLevel.CacheIfAvailable. You can specify it to set required cache level for your application.
The sample code is below.
<telerik:RadMap x:Name="radMap">
    <telerik:RadMap.Providers>
        <telerik:OpenStreetMapProvider RequestCacheLevel="Revalidate" />
    </telerik:RadMap.Providers>
</telerik:RadMap>

Regards,
Andrey Murzov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Map
Asked by
Chris
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Chris
Top achievements
Rank 1
Caleb
Top achievements
Rank 1
Mirko
Top achievements
Rank 1
Share this question
or