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
A previous PR provides cache-control HTTP header to file function in Sanic, but the best practice is to also implement the etag and the file validator.
Correct me if I am wrong:
With cache control value of no-cache, a validation is required every time before the client using the cached value. As my observation, validation request is usually a conditional request (requests that contain an If-None-Match or an If-Modified-Since header) to the resource URL. If the cached content is validated and the HTTP method is GET or HEAD, a 304 Not Modified response can be sent to the client, which is faster and smaller because it doesn't have to contain the file in the body. Validation is checking the conditions in a conditional request.
I think Sanic already supports 304 response in static file. I am wondering if we can do the same for file response in a general route handler.
The text was updated successfully, but these errors were encountered:
A previous PR provides
cache-control
HTTP header tofile
function in Sanic, but the best practice is to also implement the etag and the file validator.Correct me if I am wrong:
With cache control value of
no-cache
, a validation is required every time before the client using the cached value. As my observation, validation request is usually a conditional request (requests that contain an If-None-Match or an If-Modified-Since header) to the resource URL. If the cached content is validated and the HTTP method is GET or HEAD, a 304 Not Modified response can be sent to the client, which is faster and smaller because it doesn't have to contain the file in the body. Validation is checking the conditions in a conditional request.I think Sanic already supports 304 response in static file. I am wondering if we can do the same for
file
response in a general route handler.The text was updated successfully, but these errors were encountered: