Output Caching

Follow

By default, any page that is dynamically generated with Agility is output cached. This provides a great performance improvement for your website by allowing a page that has already been rendered once to simply return the pre-rendered HTML code.

Settings

Output Caching can be turned on and off within the Agility Content Manager in the Settings >Caching section.  By default, the output cache timeout is set to 300 seconds (5 minutes). This value can be increased or decreased depending on your needs. The higher the value that is set the staler your website content may be and the lower the value the lower the performance gain.

Please note that when a website is being developed and the site is set to run in Development Mode output cache is not enabled. Output cache is only turned on when a site is not in Development Mode (aka Live Mode).

Publishing Pages and Content

Output cached pages can become stale and out of date normally but Agility tries to remove this issue by clearing output cache on pages when they are published. The same goes for modules and content within those modules. The Agility.Web.dll maintains relationships contained within your content structures to ensure that cache is cleared when a change is made and published down to your website. In most cases you will receive all the performance gain without having stale data as long as you are not adding custom data to a page from an exterior data source like a database.

Page URL’s and Custom Output Cache

By default there is a new output cache for each page url within your site. This does NOT include different query string values such as:

http://www.MyAgilitySite.com/Blog.aspx?BlogID=123

OR

http://www.MyAgilitySite.com/Blog.aspx?BlogID=456

By default, only the page path is used to create the cache key. 

We run into a problem when we build custom logic on the server side which loads data based on querystring, a cookie, session variable, etc. To explain this scenario I will use the example of a Profile Update Page.

Say we have the url:
http://www.MyAgilitySite.com/Profile.aspx

This page will on the server side read in the currently logged in users User ID and load their specific profile. By default with output cache the first user will load the page and see a valid profile page. If a second user loads this page within the 5 minute output cache timeout they will see the profile of the first user to load the page. This of course is a very bad thing and needs to be handled by the developer.

0 out of 1 found this helpful

Comments

1 comment
  • Within your Agility Advanced Developer Training documentation PDF, the section of "Caching and Performance" is very useful, and I would expect the same information to be within your knowledge base.

    This article should include the information there, especially about the part about "Handling Querystrings and Output Caching" where one can use HttpContext.Response.Cache.VaryByParams["*"] = true; to stop query string parameters from being cached.

    You should seriously consider transcribing all the sections of the "Agility Advanced Developer Training" to your knowledge base :)

    1
    Comment actions Permalink

Please sign in to leave a comment.