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 think that's because how the library works. The cache manger only updates a file when the file is expired (validTill is before the actuall date). When it updates a file it then uses the Etag to determine if there is a newer file on the server. The cache headers include a tag must-revalidate that manages such stuff but the library doesn't support that.
Indeed, the library only checks if the file is up to date when the max-age is passed and so the cache is expired. If the etag is still the same it updates the age, otherwise the file is refreshed.
About the must-revalidate:
"Because a cache MAY be configured to ignore a server's specified expiration time, and because a client request MAY include a max- stale directive (which has a similar effect), the protocol also includes a mechanism for the origin server to require revalidation of a cache entry on any subsequent use. When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to asubsequent request without first revalidating it with the origin server. (I.e., the cache MUST do an end-to-end revalidation every time, if, based solely on the origin server's Expires or max-age value, the cached response is stale.)"
So must-revalidate only says that a cache has to revalidate when a cache is expired, this is normally optional.
As far as I know this library follows the defined http logic. If you want to get the update faster set the max-age lower.
Activity
The-Redhat commentedon Oct 11, 2018
I think that's because how the library works. The cache manger only updates a file when the file is expired (validTill is before the actuall date). When it updates a file it then uses the Etag to determine if there is a newer file on the server. The cache headers include a tag
must-revalidatethat manages such stuff but the library doesn't support that.renefloor commentedon Oct 13, 2018
Indeed, the library only checks if the file is up to date when the max-age is passed and so the cache is expired. If the etag is still the same it updates the age, otherwise the file is refreshed.
About the must-revalidate:
"Because a cache MAY be configured to ignore a server's specified expiration time, and because a client request MAY include a max- stale directive (which has a similar effect), the protocol also includes a mechanism for the origin server to require revalidation of a cache entry on any subsequent use. When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to asubsequent request without first revalidating it with the origin server. (I.e., the cache MUST do an end-to-end revalidation every time, if, based solely on the origin server's Expires or max-age value, the cached response is stale.)"
So must-revalidate only says that a cache has to revalidate when a cache is expired, this is normally optional.
As far as I know this library follows the defined http logic. If you want to get the update faster set the max-age lower.
shabanov-krl commentedon Aug 24, 2023
@renefloor
Web browsers check the etag every time a file is requested and update the cache if the etag does not correspond to what is in the cache.
Why can't this package do the same?
I need the cache to be updated if the image has changed on the server.
Merge pull request Baseflow#23 from superlistapp/main