RequestReduce icon indicating copy to clipboard operation
RequestReduce copied to clipboard

Disable ASP.NET response caching when Request Reduce has not compeleted reducing

Open candrews opened this issue 13 years ago • 3 comments

If request reduce has not "done it's thing" for a given request (in other words, not all CSS/JS has been reduced yet), it should tell ASP.NET to disable response caching. That way, non-request reduced responses will not be cached at the browser, proxy, or IIS level.

My problem right now is that I have ASP.NET output caching enabled, so the first generated response is cached. And since it's the first response, RR has not done its magic yet, and the non-RR'ed response ends up cached and served for all subsequent responses - the RR content is never used.

To do disable caching, you'd do this:

Response.Cache.SetCacheability(HttpCacheability.Private);

candrews avatar Jun 05 '12 18:06 candrews

Great idea!

mwrock avatar Jun 06 '12 15:06 mwrock

It seems that ResponseTransformer.DoTransform is where the magic happens.

I believe adding

Response.Cache.SetCacheability(HttpCacheability.Private);

at ResponseTransformer.cs line 143 resolves this issue.

candrews avatar Jun 06 '12 19:06 candrews

Actually, that change is a bit too aggressive (it prevents caching of pages that could be cached).

If any resource being requested by RR has a near futures expires header or should otherwise being ignored by RR (it's in the JavaScriptUrlsToIgnore list), then ResponseTransformer.cs line 143 is always hit, and the page is never cached. So the fix for this issue has to take into account ignored urls.

candrews avatar Jun 06 '12 20:06 candrews