dotless/dotless — pull request #157 by Sarkie (2012-03-16 11:11:14+00:00)
Title: My attempt at making caching correct

First pull request, if I've done something wrong :)

So what I've done, added file dependencies in HttpCache, which is creating CacheDepedencies under the hood, so if the file changes the cache will be invalidated.

You can test this by get the .less file, you'll get a 200 with an ETag (Hash of the file), then you'll get it again, the ETag will be sent with the request, the server will recalculate it and if not changed will return a 304. If you then change one of the .less files, you should get a 200 next time and the file downloaded.

If you do a Response.End() it'll end the whole of the Response, which means ASP.net code and handler code won't run. It's a Thread.Abort() I do believe. So I removed it from both Responses.

I also removed caching from CssReponse, since I didn't think it should do any caching at all.

I removed setting of MaxAge because SetExpires supersedes it.

Now the Vary header doesn't seem be getting sent, so I think it might be my set up, can someone test it? It should be sent when we cache, so public proxy servers no that if the Accept-Encoding header changes, they need to get a different version, I commented out the SetOmitVaryByStart() which sends the Vary:* header, so if anything changes it'll get a new version. (This is wrong I think, Vary should only be on Accept-Encoding)

I also removed commented out code.

Thoughts? Tests? I also messed around with the Web.Config to work on IIS Express and IIS, so I'm assuming you can ignore that.

Sarkie