falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.53k stars 945 forks source link

Support `ETag` for static files #2243

Open vytas7 opened 4 months ago

vytas7 commented 4 months ago

Render the ETag header when serving static files. We are already performing .stat() on the open file handle, so we should have the required data in order to build an ETag. We could use the same algorithm as the popular Nginx web server.

When serving, also check the If-None-Match header, and render HTTP 304 Not Modified if appropriate.

dominik-air commented 2 months ago

Hi! I'd be interested in helping with this enhancement. Any tips on where I should look in the project? I did some basic searching yesterday, but wasn't able to find a file/module this feature could be integrated into.

vytas7 commented 2 months ago

Hi @dominik-air! And thanks for your interest in contributing to the project!

Serving static files is implemented in falcon/routing/static.py.