Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 833 Bytes

File metadata and controls

42 lines (32 loc) · 833 Bytes

etag

See also [cache]

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Server

ETag: W/"<etag_value>"
ETag: "<etag_value>"

ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
ETag: W/"0815"

Weak etags are same content - but not byte for byte the same (caution string etags are byte for byte the same - including headers!!!)

Client Request

If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"

Server Response

304 Not Modified

sanic-org/sanic#51 (comment)

from zlib import adler32
import os.path
    if add_etags:
        headers['ETag'] = '{}-{}-{}'.format(
            int(os.path.getmtime(location)),
            hex(os.path.getsize(location)),
            adler32(location.encode('utf-8')) & 0xffffffff)