This project has moved. For the latest updates, please go here.

Client caching issue

Jan 28, 2015 at 1:17 PM
Hello all,
   I have problem with client file caching for less bundless. When client request less bundle first time, it got 200 status in response after that each time it get 304 status code. 
   I analysed url adress of the requested bundle file  and it contains version parameter that is changing after the rebuild of bundle. So that why client get file only once after that use local file from cache without additional requests thats return 304 status code.
   As for me problem in expire date header in response that is set to a year ago. I found commint of Andrew Taritsyn (Commit 4468b5471d1c by Taritsyn on 08.26.2013 07:22).  In this commit Andrew added this line of code:
  __clientCache.SetExpires( DateTime.UtcNow.Add(TimeSpan.FromDays(-365)));__
previously was possible to configure this time by config file by handlerAssets section and
use in code like this:
  __clientCache.SetExpires( DateTime.UtcNow.Add(cacheDuration));__

Jan 28, 2015 at 2:58 PM
Hello, Onell!

Recently I have already answered a similar question in the «Expires HTTP Header wrong value» issue.
Jan 28, 2015 at 4:18 PM
Thank you for answer. I resolved by problem by overriding Cache-Control header by rewrite rule like this:

    <rule name="Set custom HTTP response header">
      <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
        <add input="{REQUEST_URI}" pattern="\.less" />
      <action type="Rewrite" value="max-age=86400"/>
Now client does not request file and retrieve it from local cache.
Jan 28, 2015 at 4:42 PM
I'm glad for you, but it seems to me, that these settings can hurt in debug mode.

In any case, in release mode client-side caching of the bundle works correctly.