I want to disable the html cache for 1 item so it is always rendered.
Background:
I need to show information for companies stored in a separate database. In sitecore I have 1 item which has the user control that shows the required information and depending on a Context parameter I figure out which company to show.
The sitecore tree look like this:
/sitecore
/content
/home
/company-information
The url is: /show-company-information/[company-name]-[company-id]. I have a pipeline module that parses the url and sets the company information as the current item and adds the company id to HttpContext.Current.Items. That’s how my user control figures out which company information to render.
It all works fine in development but once you deploy it to a Content Delivery server it stops working correctly. The first time the page is accessed it gets cached and every consecutive request returns the company information that was cached the first time.
My current workaround is to clear the HTML cache for the company-info item in the same pipeline step that parses the company-information but it seems a really dirty solution.
Is there a better way to achieve the same result?
EDIT
Here is how the site is setup in web.config and also the web database configuration:
<site name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/Home/" startItem="/home" language="en-GB" database="web" domain="extranet" loginPage="/user-login.aspx" allowDebug="true" cacheHtml="true" htmlCacheSize="400MB" registryCacheSize="500KB" viewStateCacheSize="500KB" xslCacheSize="20MB" filteredItemsCacheSize="20MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<!-- CACHE SIZES -->
<cacheSizes>
<sites>
<website>
<html>500MB</html>
<registry>500KB</registry>
<viewState>500KB</viewState>
<xsl>200MB</xsl>
</website>
</sites>
</cacheSizes>
<database id="web" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
<param desc="name">$(id)</param>
<icon>Network/16x16/earth.png</icon>
<securityEnabled>true</securityEnabled>
<dataProviders hint="list:AddDataProvider">
<dataProvider ref="dataProviders/main" param1="$(id)">
<disableGroup>publishing</disableGroup>
<prefetch hint="raw:AddPrefetch">
<sc.include file="/App_Config/Prefetch/Common.config" />
<sc.include file="/App_Config/Prefetch/Web.config" />
</prefetch>
</dataProvider>
</dataProviders>
<indexes hint="list:AddIndex">
<index path="indexes/index[@id='articleIndex']" />
</indexes>
<proxiesEnabled>false</proxiesEnabled>
<proxyDataProvider ref="proxyDataProviders/main" param1="$(id)" />
<archives hint="raw:AddArchive">
<archive name="archive" />
<archive name="recyclebin" />
</archives>
<Engines.HistoryEngine.Storage>
<obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
<param connectionStringName="$(id)" />
<EntryLifeTime>30.00:00:00</EntryLifeTime>
</obj>
</Engines.HistoryEngine.Storage>
<cacheSizes hint="setting">
<data>400MB</data>
<items>400MB</items>
<paths>10MB</paths>
<standardValues>1MB</standardValues>
</cacheSizes>
</database>
</databases>
Page layouts structure:
layout - no output caching
- sublayout - no caching options ticked
- offending sublayout - no caching options ticked
Are we doing anything wrong for this to be cached so aggressively?
You can use the CacheManager to turn off caching during the Page Load event then turn it back on in PreRender. This will ensure that the page’s html / xslt controls are not cached.
The CacheManager Class has the following method used by all controls when retrieving HTML caches
So setting the Enabled Property to false will stop the controls being rendered from the cache:
Its brutal but it works.