0

I want to enable cache for static contents of my website. I found this method using IIS cache control option which I guess it works serverside:

    <caching>
        <profiles>
            <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
            <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
        </profiles>
    </caching>

Also I found this solution for client side cache of static contents:

    <staticContent>
        <clientCache cacheControlMaxAge="7.00:00:00" cacheControlMode="UseMaxAge" />
    </staticContent>

After adding both of above codes, I have cleared history and used hard refresh. But when I check network tab in Chrome console, the loading time of static content are still in seconds (not from user cache). I have to say that the check box to disable cache is also unchecked in developer console.

Edit: After updating kernelCachePlicy to CacheUntilChange I have used netsh http show cachestate to check state of cache and this is a sample output, but the browser still loads file from server not from local cache.

URL: [PTAH TO A PNG FILE]
    Status code: 200
    HTTP verb: GET
    Cache policy type: User invalidates
    Creation time: 2017.11.1:20.41.18:0
    Request queue name: MyPool
    Content type: image/png
    Content encoding: (null)
    Headers length: 244
    Content length: 1507
    Hit count: 5
    Force disconnect after serving: FALSE
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82
  • Since you cleared browser history nd did hard refresh that’s why static content is loaded from server instead of cache. What happens if you just do normal refresh (F5 button)? Static content should serve from cache – Mohsin Mehmood May 28 '18 at 13:27
  • no difference even I try F5 many times. Every time all content are loaded from server @MohsinMehmood – Ali Sheikhpour May 28 '18 at 14:24
  • Do server side digging please, https://learn.microsoft.com/en-us/iis/manage/managing-performance-settings/configure-iis-7-output-caching#troubleshoot-caching – Lex Li May 28 '18 at 15:24
  • I have edited the question by adding results of digging @LexLi – Ali Sheikhpour May 29 '18 at 06:40

0 Answers0