Skip to content
April 12, 2011 / kiranpatils

400 Bad request while getting images

Challenge:

Last week we was facing strange issue, When we access any site and it has Image embedded within it, First time it comes fine. But after that when user presses Refresh [F5] it shows “Bad Request” and when we do SHIFT + F5 [Hard Refresh] it works fine.

We checked so many things Browser Cookies/Temp directory etc. But finally one Web.Config did the trick. Eager to know what it was.

Solution:

The IIS Kernel Cache should be disabled for the Sitecore application as it may cause issues with processing dynamic image requests and cause errors, such as the one described above. To disable IIS Kernel Cache, add an enableKernelOutputCache=”false” attribute to “httpRuntime” section of web.config:

<httpRuntime maxRequestLength=”16384″ executionTimeout=”600″ enableKernelOutputCache=”false” />

Do you know why it was causing an issue?

We did more research and found that why it was causing an issue.

1. MSDN Article at here http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.enablekerneloutputcache.aspx explains this stuff in detail.

In order to cache a response, the following criteria need to be met:

  • Caching must be explicitly enabled by a page directive or by the caching API.
  • Caching must have an expiration policy so that the kernel knows when to discard it.
  • Caching cannot have any variable headers or parameters.
  • The request must not require any authentication.
So, as per my theory Sitecore guys violated criteria#3 – Caching cannot have any variable headers or parameters. And might have added few headers or parameters, which was causing this issue.
Just a note : This behavior is not relevant for operating systems running IIS 7 and later
Good to read :
Advertisements

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

%d bloggers like this: