You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using AttributeBasedCacheControlPolicy with CacheControlHeaderValue that cache privately for a couple of days by default.
When I use HttpCacheControlPolicy(false, 600) in an action, the first request responded as expected "Cache-Control: public, must-revalidate, max-age=600". However the subsequent request (after 600 second or expired) , contain "Cache-Control: no-cache" even though the HTTP status is correct "304 Not Modified". I expect it should always "Cache-Control: public, must-revalidate, max-age=600" to perform 'sliding' expiration.
I inspect using Fiddler
The text was updated successfully, but these errors were encountered:
Without using HttpCacheControlPolicy attribute, the default cache config like the code below also only applied on the first request as "Cache-Control: no-transform, must-revalidate, max-age=600". The subsequent request will be "304 Not Modified" with "Cache-Control: no-cache".
The behaviour is correct. Cache Header directives are irrelevant for a 304 response since the cache headers must be sent with the original response:
If the status code is 304 (Not Modified), the cache uses the entity- body stored in the cache entry as the entity-body of this outgoing response.
As you can see, there is no mention of headers here. Hope this helps.
In terms of examples outside, sites implement 304 differently. I have seen one that sends cache control and another only ETag. As I said the headers are irrelevant.
I am using
AttributeBasedCacheControlPolicy
withCacheControlHeaderValue
that cache privately for a couple of days by default.When I use
HttpCacheControlPolicy(false, 600)
in an action, the first request responded as expected "Cache-Control: public, must-revalidate, max-age=600". However the subsequent request (after 600 second or expired) , contain "Cache-Control: no-cache" even though the HTTP status is correct "304 Not Modified". I expect it should always "Cache-Control: public, must-revalidate, max-age=600" to perform 'sliding' expiration.I inspect using Fiddler
The text was updated successfully, but these errors were encountered: