0.4.0 - HTTPCache
HTTPCache
Overview
HTTP caching occurs when the browser stores local copies of web resources for faster retrieval the next time the resource is required. As your application serves resources it can attach cache headers to the response specifying the desired cache behavior.
When an item is fully cached, the browser may choose to not contact the server at all and simply use its cached copy:
HTTP cache headers
There are two primary cache headers, Cache-Control and Expires.
Cache-Control
The Cache-Control header is the most important header to set as it effectively switches on caching in the browser. With this header in place, and set with a value that enables caching, the browser will cache the file for as long as specified. Without this header, the browser will re-request the file on each subsequent request.
Expires
When accompanying the Cache-Control header, Expires simply sets a date from which the cached resource should no longer be considered valid. From this date forward the browser will request a fresh copy of the resource.
This Introduction to HTTP Caching is based on the HTTP Caching Guide.
AuthX provides a simple HTTP caching model designed to work with FastAPI,
Initialize the cache
from authx import HTTPCache
from pytz import timezone
africa_Casablanca = timezone('Africa/Casablanca')
HTTPCache.init(redis_url=REDIS_URL, namespace='test_namespace', tz=africa_Casablanca)- Read More in the New Documentation: https://authx.yezz.codes/configuration/cache/httpcache/
What's Changed
- chore(docs): Improve Documentation by @yezz123 in #209
- chore(dev): refactor code & improve some exceptions ✨ by @yezz123 in #212
- ref: Use the built-in function
nextinstead of a for-loop. by @yezz123 in #213 - chore(docs): add New Sponsors ✨❤️ by @yezz123 in #214
- docs(mkdocs.yml): Change name from
middlewarestomiddlewareby @theoohoho in #215 - chore(f/l): Integrate
Pyupgradeto AuthX Environment by @yezz123 in #216 - chore(feat): Integrate HTTP Caching Model for authx ✨ by @yezz123 in #217
- docs: add theoohoho as a contributor for doc by @allcontributors in #218
- chore(Example): Provide New Cache Example✨ by @yezz123 in #219
New Contributors
- @theoohoho made their first contribution in #215
Full Changelog: 0.3.1...0.4.0

