⚡️(backend) implement etag and last_modified headers to fetch content

We want to give to the js client the ability to use some headers to
avoid fetching a content it already have. For this, the content endpoint
will return an ETag and Last-Modified headers corresponding to the file
content ETag and its last modification. For future fetch, the client can
use the If-None-Match or If-Modified-Since request headers, if one of
these headers are satisfied, the endpoint will return a 304 response. If
not it will still return a 200
This commit is contained in:
Manuel Raynaud
2026-04-27 15:07:33 +02:00
parent b6c6fc8217
commit 6f2cd8a829
4 changed files with 332 additions and 10 deletions
+5
View File
@@ -194,3 +194,8 @@ class AIUserRateThrottle(AIBaseRateThrottle):
if x_forwarded_for
else request.META.get("REMOTE_ADDR")
)
def get_content_metadata_cache_key(document_id):
"""Return the cache key used to store content metadata."""
return f"docs:content-metadata:{document_id!s}"