Hot answers tagged

28

You can do this by making sure that your renderings are set to Vary by User. This adds the user to the cacheKey string like this "_#user:" + Context.GetUserName(); You can then use the following code to clear the html cache for that user: // Need to clear the cache for the header and the user profile.... var htmlCache = CacheManager.GetHtmlCache(Context....


18

You can turn cache off at the site level in the site definition in configuration: <site name="website" enableTracking="true" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="...


17

It could be that you just have a dodgy rendering that is running on every page and is then cached for that page; to see if this is the case you can profile Sitecore pages. You can investigate this by clicking on the "Debug" option and scrolling to the bottom of the page to see the speed of renderings: From here you can either optimise the code, or check ...


17

Other option is to delete from time to time media cache using an schedule agent. Current value is 24 days but if you need to clear more ofen just decrease max age parameter of the last setting (see below settings). It is not recommended to clear media cache very often because you will have some performance impact. <agent type="Sitecore.Tasks....


17

Just for clarification of how HTML cache works, the remote CD servers need to know about the CM server publish event. That setting is EnableEventQueues. If it is set to true on the remote server, the remote listen for the CM end:publish event. <setting name="EnableEventQueues" value="true"/> Then on the CM server you need to make sure the publish:...


15

I would use a remote event that can be raised on the CM server and subscribed to by the CD servers. When the event is raised, an event handler can execute on the CD servers clearing the cache. This is the mechanism used by the HtmlCacheClearer handler that comes with Sitecore, you can see how it is setup in the default Sitecore.config: <event name="...


14

It is completely safe to just delete the folder /App_data/MediaCache without causing disruption. The minute an image gets called up again, it will be cached again, so no worries about the functionality of your website. We make sure it get's cleaned up every week. In addition you can set up a clean up job to do the work for you. Unfortunately the usage of /...


13

Prefetch cache This is item data pulled out from the database when the site starts up - from the Sitecore docs: "Each database prefetch cache entry represents an item in a database. Database prefetch cache entries include all field values for all versions of that item, and information about the parent and children of the item. Populating the prefetch ...


13

I typically disable caching for my local environment by setting the HTML cache lifetime to 1 second using the following config patch: <setting name="Caching.HtmlLifetime"> <patch:attribute name="value">00:00:01</patch:attribute> </setting> To make this specific to your local environment, you can patch it in using a configuration ...


13

Vary By options each serve different use cases, and are not always applicable when caching a rendering. If a component doesn't have a data source then Vary By Data will cache its output by the Context Item. This would cause a cached instance of this component for every page. If a component outputs the same markup everywhere, then you don't want to apply ...


12

Possible answers to 1,2,3... Sounds like you need to do a bit of tuning on your caches. Sitecore has a number of "admin" pages which help you diagnose problems such as this - you can use the cache admin page to monitor the current size, configured size and vectors of the individual caches, include prefetch. To access this page, browse to http:///sitecore/...


12

Yes, use the glassCache attribute. A value of anything other than false means the cache will be enabled for that site: https://github.com/mikeedwards83/Glass.Mapper/blob/master/Source/Glass.Mapper.Sc/SitecoreService.cs#L116


11

The DefaultScavengeStrategy is responsible for scavenging (freeing up) memory from your caches when your application is maxing out on its memory resources, as determined by the configured cache size limits. The warning that you are seeing indicates that memory usage was maxing out for the specified cache, based on your configured maximum cache sizes, and so ...


10

You can remove access to /sitecore/templates/System/Layout/Rendering Parameters/Standard Rendering Parameters/Caching Navigate to the item Open Security tab Click on Assign button In the dialog which will appear select user or group (preferably) from whom you would like to hide the section Remove the inheritance for the item and its descendats


9

I typically do what you're doing and set all the renderings I want cached to be cacheable. However, for my local development, I will set cacheHtml to false on the site definition. <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <sites> <site name="mySite" patch:before="site[@name='website']" ...


8

Do we need to include both master and web db settings in CMS? Or just master settings in CMS. Only the master db will suffice. Web db items are only used when the site is accessed through the front-end which is usually not the case on CMS. Do we need to include master and web db settings in CD? Or just Web settings in CD. Only the web db. The master db is ...


8

Sitecore comes with out of the box possibilities to configure media caching. Have a look at the Sitecore.config: <!-- MEDIA RESPONSE - CACHEABILITY The <see cref="HttpCacheability">cacheability</see> to use in media response headers. Possible values: NoCache, Private, Public, Server, ServerAndNoCache, ServerAndPrivate ...


8

If you are using Sitecore 8.0 Update 3 upwards then a couple of new default processors were added to the Health Monitors to periodically dump the Cache Status and Rendering Statistics to files on disk. By default this process is run every 10 minutes, and they are run on the CD servers as well so you can use these files to check how your caches have been ...


8

The question is quite broad and there are many ways you can achieve this obviously (you mentioned sitecore query and foreach loop). Another option would be to use the sitecore content search (with rendering cache on top, of course). So, you can define your custom POCO object with IsInFooter and IsInHeader fields and query your index. Simplified code (...


8

If Cachable attribute equals true, it means that Glass Mapper will apply cache for this object. I've decompiled the Glass.Mapper.Sc.dll, where CacheKeyGenerator is defined and we can see that it doesn't consider the language in the key for cache: namespace Glass.Mapper.Sc.Caching { public class CacheKeyGenerator : ICacheKeyGenerator { public string ...


8

If you do not want to disable cache size limits (which in our situation can cause memory issues when building large indexes on Azure WebApps), you can use the following Sitecore setting to change the "web[isLanguageFallbackValid]" and "master[isLanguageFallbackValid]" sizes: <sitecore> <settings> <setting name="Caching.SmallCacheSize" ...


7

You have it right, the Page refers to the fully rendered HTML Markup of the page. This would include all renderings on that page that are not ajax'd in after the page load in the browser. media, CSS and JavaScript MAY still be cached, but it doesn't mean they WILL be cached. You have to setup the cache control headers for static assets outside of Sitecore. ...


7

Rather than disable the HTML cache for that page, why not use the Vary by Query String option on your query-string-dependent renderings? I wrote an article that should help get you started, but the below should cover the basic overview of what you would be doing. The 'Vary by' Cache Options Sitecore includes support for varying HTML Cached copies of a ...


7

The cache is typically cleared when publishing, which would happen frequent enough for you to not enable this agent. Imagine a case where you don't want the cache to be cleared, perhaps due to the fact there is a ton of content getting published and you don't want it to refresh every single time an item changes. You could then use this to refresh it once a ...


7

Adding a unique URL parameter will force the browser to request the updated image, as mentioned by both the other answers. You'll also face this same issue if you are using a CDN by the way and using the same technique works well in this situation too. I provided code for an updated MediaProvider in my post about CDNs. This will ensure you don't need to ...


7

Make sure to check "publish subitems" when publishing parent folder. To verify if the item was removed from the web database, switch to web database from Sitecore Desktop and see if your page is there. Open .../sitecore/shell/ in the browser and on the bottom right corner of the screen there is a button to switch database. Switch back to master database ...


7

It's been a while since I dug into this, but if you're using Sitecore's security mechanisms to authenticate visitors to your public site (served by the CD environment), you'll want the AccessResultCache to improve the speed of that data access effort (querying .Net membership or however you may have extended it...). In this case, performance improvements can ...


6

I have just manually deleted the folders under App_Data/MediaCache/[site name] on each CD server. Never seems to have caused disruption since Sitecore will fetch the image from the database again if it does not find a cached version.


6

There are only two viable options; short of simply not building up navigation structures in this manner. I would normally have any form of navigation being components of their own, and have a menu hierarchy of navigational items define what they show. But that's a separate story. Content Search As already demonstrated by @Andrey Bobrov. Performance wise, ...


6

If you are referring to HTML Cache, by default, Sitecore includes cache-clearing event handlers that clear the HTML cache when the publish:end and publish:end:remote events are raised. The handler is typed to the Sitecore.Publishing.HtmlCacheClearer class and calls the ClearCache method. You can find the subscriptions for these events in your ShowConfig (/...


Only top voted, non community-wiki answers of a minimum length are eligible