locked
ARR Disk cache return 200 instead of 304 for cached files RRS feed

  • Question

  • User-734717073 posted

    I have a server farm and ARR in front of it. If ARR disk cache is not enabled everything works as expected. Request/responses contain cache control headers, etags and when I click refresh in browser the servers in farm return 304 not modified.

    When I enable Disk cache I see the files cached correctly on disk, but when ARR returns data from such disk cache it always answers with HTTP 200 OK instead of 304 not modified so the browsers downloads the same data again!

    Here is request response headers when I enable disk cahe and response is served by ARR disk cache

    request:

    GET /~/media/Images/Catalog/Products/25312_2.png HTTP/1.1
    Host: media.whatever.com
    Connection: keep-alive
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: cs-CZ,cs;q=0.8
    If-None-Match: b630671342a345bf96d6b471ac578e65
    If-Modified-Since: Thu, 22 May 2014 07:29:55 GMT

    response:

    HTTP/1.1 200 OK
    Cache-Control: public, max-age=604800
    Content-Type: image/png
    Expires: Fri, 20 Jun 2014 10:30:20 GMT
    Last-Modified: Thu, 22 May 2014 07:29:55 GMT
    Accept-Ranges: bytes
    ETag: b630671342a345bf96d6b471ac578e65
    Server: Microsoft-IIS/8.5
    Content-Disposition: inline; filename="25312_2.png"
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    X-Powered-By: ARR/2.5
    Date: Fri, 13 Jun 2014 12:02:24 GMT
    Content-Length: 38788

    Please note same ETag, same Last-Modified yet it returns HTTP 200

    And here is same one when ARR disk cache is disabled and the request hits the backend server which correctly responds with 304

    GET /~/media/Images/Catalog/Products/25312_2.png HTTP/1.1
    Host: media.whatever.com
    Connection: keep-alive
    Cache-Control: max-age=0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: cs-CZ,cs;q=0.8
    If-None-Match: b630671342a345bf96d6b471ac578e65
    If-Modified-Since: Thu, 22 May 2014 07:29:55 GMT
    HTTP/1.1 304 Not Modified
    Cache-Control: public, max-age=604800
    Expires: Fri, 20 Jun 2014 12:07:03 GMT
    Last-Modified: Thu, 22 May 2014 07:29:55 GMT
    ETag: b630671342a345bf96d6b471ac578e65
    Server: Microsoft-IIS/8.5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    X-Powered-By: ARR/2.5
    Date: Fri, 13 Jun 2014 12:07:03 GMT
    


    I tried to modify IIS static file caching settings on ARR machine, disabled compression but with no difference. 

    To me it looks like this should be not related to IIS caching but looks like bug/feature of the the disk cache module as it is the logic of disk cache code to determine the file is in the cache and the etag/date is correct (?)

    Anyone has this working correctly? Any tips how to troubleshoot this?

    Friday, June 13, 2014 8:33 AM

Answers

  • User-1183935731 posted

    It has been noticed that if the ETAG (If-None-Match) is not present in the header, then the ARR server returns Http304.

     trying to figure out how/why ETAG causes this issue in ARR..

     

    Looks like its better to disable ETAG from IIS completely on Web Farms (including Reverse Proxies with ARR):

    See section "Configure ETags"  in  the link https://developer.yahoo.com/performance/rules.html

     

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, June 26, 2014 4:30 PM

All replies

  • User1183424175 posted

    Hi,

    I think you can try setting smaller value(memory cache duration) for the arr disk cache or disable the cache. For more information, you can refer here

    http://www.iis.net/learn/extensions/configuring-application-request-routing-(arr)/configure-and-enable-disk-cache-in-application-request-routing

    HOpe it can help you.

    Monday, June 16, 2014 2:07 AM
  • User-734717073 posted

    It made no difference. Both setting memory cache duration to 1 or 0 in web farm Cache setting and also turning off IIS cache (IIS Admin -> Output Caching -> Edit Feature Settings - uncheck both caches). Still  200 instead of 304 when serving file from disk cache.

    maybe the caching code is so simple that it always returns everything backend server sent including HTTP code? If one looks how the  files are cached on disk (those *.full files) - there are all response headers and http result code inside, maybe it just returns it all as is?

    Anyone verified ARR can return code 304 for cached files at all (when really served from cache, not when hitting backend server)?

    Tuesday, June 17, 2014 9:53 AM
  • User-1183935731 posted

    It has been noticed that if the ETAG (If-None-Match) is not present in the header, then the ARR server returns Http304.

     trying to figure out how/why ETAG causes this issue in ARR..

     

    Looks like its better to disable ETAG from IIS completely on Web Farms (including Reverse Proxies with ARR):

    See section "Configure ETags"  in  the link https://developer.yahoo.com/performance/rules.html

     

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, June 26, 2014 4:30 PM
  • User-2023626981 posted

    Hi Yasin,

    After removing ETags from IIS, ARR is now sending 304 as status code for cached requests. Thanks for the solution Smile

    IIS Outbound rule can be used to remove to Etags from response.

    See below SO answer for more details:

    http://stackoverflow.com/questions/477913/how-do-i-remove-etag-headers-from-iis7/18025228#18025228

    Friday, June 27, 2014 3:32 AM
  • User-734717073 posted

    Thanks, it helped.

    Looks like its better to disable ETAG from IIS completely on Web Farms (including Reverse Proxies with ARR):

    See section "Configure ETags"  in  the link https://developer.yahoo.com/performance/rules.html

    Well this is a bit misleading. If servers cannot generate same etags for same resources across web farm due to some bug/feature than indeed you cannot use it. However this was not our case. We are serving static resources from shared storage and it is not a problem to generate same etag values across our web farm. So the proposed workaround works but we miss the etags. It is useful feature and it is unfortunate we must disable this due to this bug in ARR.

    Wednesday, November 11, 2015 3:07 AM