Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
Sitefinity's built in caching mechanism caches cached objects by relative path, rather than by the full path. Sometimes you may need to display the same page in different sub-domains, and have different information displayed based on what sub-domain the user is on. The purpose of this blog post is to sample how to modify the built in caching providers to store keys for cached objects with a bit more information than the relative path. The code for this sample is provided by Sitefinity Senior Developer Vladimir Vasilev.
Sitefiniy comes with two caching providers built-in. They are declared in your web.config in the <caching> config element of the <framework> configuration section:
Then in the <cms> configuration element you set the default page provider to use either of those two providers. The default setting is to use the ASPNET caching provider, which is a wrapper of the built in ASP.NET caching provider:
Based on what you have configured for the caching provider you have two apply one of the bellow described modifications. If you are using ASPNET caching provider, you just have to modify the Global.asax file to add the host name in the key generated for cached objects:
String.Concat(context.Request.RawUrl, context.Request.Browser.Type, context.Request.Url.Host).ToLower();
If you are using the MemoryCachingProvider you have to create a custom provider which will inherit from the built-in one and extend the methods for inserting cached objects and retrieving them. Sample code can be found bellow:
/// Summary description for CustomMemoryCachingProvider
//generate new key based on relative url, domain name, and browser type
HttpContext context = HttpContext.Current;
.Concat(oldKey, context.Request.Url.Host, context.Request.Browser.Type);
//insert the custom key instead of original one
value, System.Web.Caching.CacheDependency dependencies,
.Insert(GetNewKey(key), value, dependencies, duration, slidingExpiration);
//get cached object based on custom key
After you have implemented the custom MemoryCachingProvider you have to substitute the built-in one with yours in web.config:
The above implementation samples how you can easily customize the caching providers to include additional information for objects being stored in cache. You can also include additional information in the key.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.