Sitecore Postbacks not working? Contents not updated on button click? Try removing caching from your rendering

This is a classic Sitecore blunder – suddenly postbacks or button clicks have no effect, as if the web site no longer are connected to your webforms codebehind or the MVC renderings. And you have not changed any code.

But have you enabled caching of your rendering?

Sitecore Caching Settings

Sitecore Caching Settings

The Sitecore rendering cache is a true HTML cache. The output markup of the rendering is cached, and the contents of the cache is stored in one or more versions, depending of your choices:

  • Clear on Index Update: Cache cleared when the item is updated in the index
  • Vary By Data: One cache per URL
  • Vary By Device: One cache per device
  • Vary By Login: One cache for anonymous users, another for authenticated users
  • Vary By Parm: One cache per rendering parameter
  • Vary By Query String: One cache per query string parameter
  • Vary by User: On version per user

So a true HTML cache means that your code is called once, and the next time the rendering is rendered, the contents is a string-output operation of the markup stored in the cache. So there is no postbacks from Webforms. Or if you expect the MVC rendering to update the markup on a button click – that’s not going to happen.

Caching have 2 further properties:

  • Your caching settings can be overridden on the presentation details of an item.
  • If a cached rendering have a placeholder containing other renderings, the renderings in the placeholder is also cached.

BTW, you can always clear the cache: Check out the /sitecore/admin/cache.aspx page, or read about how to clear cache individually from code.

MORE TO READ:

 

Advertisements

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in Sitecore 5, Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s