filipw / Strathweb.CacheOutput

ASP.NET Web API CacheOutput - library to allow you to cache the output of ApiControllers
Other
882 stars 253 forks source link

Etag not sent with Strathweb.CacheOutput.WebApi2 #133

Open justinhomes opened 9 years ago

justinhomes commented 9 years ago

Using .net 4.5 MVC WEb Api with 'Strathweb.CacheOutput.WebApi2 0.6. This is my web api method

    [HttpGet]
    [ApiValidateAntiForgeryToken]
    [CacheOutput(ClientTimeSpan = 100, MustRevalidate = true)]
    public HttpResponseMessage GetCountryCodes()

This is how the response header looks like

    Arr-Disable-Session-Affinity:true
    Cache-Control:must-revalidate, max-age=100
    Content-Length:15303
    Content-Type:application/json
    Date:Sun, 28 Jun 2015 03:27:49 GMT
    Server:Microsoft-IIS/8.5
    X-AspNet-Version:4.0.30319
    X-Frame-Options:AllowAll
    X-Powered-By:ASP.NET

it does not have an Etag in response header, so when the cache expires it does not check to see if the content has been modified and send back 304.

pritamkarmakar commented 9 years ago

According to me if in the request header we are sending etag as 'If-None-Match:"" and if server cache has same etag then response will not contain any etag, this is expected behavior. But if the etag doesn't match (local vs server) and you still don't see new etag in the response then its a bug.

justinhomes commented 9 years ago

this is how my first request looks like.

Accept  
*/*
Accept-Encoding 
gzip, deflate
Accept-Language 
en-US,en;q=0.5
Content-Type    
application/json
Cookie  
ASP.NET_SessionId=kzzqwvabek40lfwkpwiajbel; __RequestVerificationToken=tTqDCM1IEjOOU08KICeWHDZpCxCWofvqXGK_qk_fhtaBWKHqAS032Ktp1CkSFyTDc-Kn0taW2yuMPy1De4DcnF5bjM8F7zOBF1fQqSHVk1E1
; _ga=GA1.2.1210312127.1435985446; _gat=1; .AspNet.ApplicationCookie=OnKDItcwvSxJ-qCNXDiq_mzVSb72z5p
X80I1hw1xjuXnk1nmFhHK_prZGOlyDBPWZAgoOubCdiXAlqnMb1SgKw7z5djWrstQFUT66iv1Kn6_p2bgdreqLkkuVtdApGECgHu
ezk_PsFPVD_H0Xi9bU3CcX-5LPmtCqqWCrGwqIM6zeQebRSlhwmF2xu6IG11drcJF0tmeYF9NBVJkhcsArGEeugwSsrV9D4bhw13
JHsRgRYCtRcY-A9lIyIL-rwF9dkg0CDrFO80mtZwryq4nFszreIHQkjfhhtqohgBWmcxGP7XqgNbjarjLeubHcZhcHJprjlPxqSk
Mgb9gj8dcJJ07Gm66dux6JFApqzgWKy0LoRK6WI4dcyVJ1InuMzj8I6aCLnQxqyuJPkEiaxUvDz8buMe3mPwBoVaIkVuuI9Y72Nt
lSVpDtuJ_shHiS7WNmgDkminwVhrvtj5SieDuzxbJ2tNOF2KZ2AXErEBBbS8mRc4wn_Q0m_4xJCDWNxVO
DNT 
1
Host    
localhost.com
Referer 
https://localhost.com/
RequestVerificationToken    
gzEnXTFGpjx8wbm7vUvel0Z76qNVRAeWGJRq5sFWSXdV4W6Vw2Ssivt8c5qF-IBgHsgD6pBo1MsD51QL-7xF-N3hC8dTJKmRMuF1HafvRCE1
:K0x0OQcoQODSSS0z7gHv9UKoJ5-u6RpaehSE3bBogibMgg-hcGKx8NODYC1TRvcePBbNI1eravtwZ908oCy_ZAznkg0dnzhWSiO
-el6JE-g81LAHTLkB0LINcjuki2lNnSP4N0iy753Pm0hXLQkSvw2
User-Agent  
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
X-Requested-With    
XMLHttpRequest  
filipw commented 9 years ago

can you add a repro project? I can't reproduce it

kalaondr commented 5 years ago

According to me if in the request header we are sending etag as 'If-None-Match:"" and if server cache has same etag then response will not contain any etag, this is expected behavior. But if the etag doesn't match (local vs server) and you still don't see new etag in the response then its a bug.

According to RFC 7232:

4.1. 304 Not Modified

[...] The server generating a 304 response MUST generate any of the following header fields that would have been sent in a 200 (OK) response to the same request: Cache-Control, Content-Location, Date, ETag, Expires, and Vary.