I am enabling output caching in my Sitecore-enabled ASP.NET site by putting this in my default.aspx (which lives outside the CMS):
<%@ OutputCache Duration="300" VaryByParam="None" %>
and in my Web.config:
<setting name="DisableBrowserCaching" value="false" />
This works when I hit my page directly, as in http://[website]/default.aspx, but not when I browse to the root site http://[website]/. In this case it always returns a 200 response, rather than 304 (not modified) on repeat requests.
I have tried the same in a website that does not use Sitecore, and caching works in all instances under IIS 7 and with Sitecore 6.4.1.
How do I enable output caching for default (extensionless) ASP.NET pages in a Sitecore-enabled site?
Update:
Seems to work on my local machine (this issue was in our QA environment), only difference I can see is that I have IIS 7.5 rather than 7.0, but same web.config and Sitecore instance.
Also, I have created another test page (http://[website]/Test/default.aspx) which exhibits the same behavior, so it is not only the root that is affected.
Update 2:
Bad news - Sitecore have confirmed that Output Caching is not officially supported:
"Sitecore CMS was not designed to work with enabled User-mode or Kernel-mode output caching in IIS and does not support its usage."
This doesn't explain why it sometimes works for specific URLs and environments, and I would still appreciate a workaround.