-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is the cache-control
header set?
#156
Comments
Could you please clarify your use case and what you want to achieve or share a small code example? If you are talking about caching HTTP responses with a minimal setup on your side, then you can look at https://github.com/requests-cache/aiohttp-client-cache or https://github.com/requests-cache/requests-cache |
When HTTP page response get cached, shouldn't there also be directives communicated to the CDN and client through As far as I can tell, the For example, using
Handling ETags are another matter. |
Also, my apologies if I'm conflating the intended usage. It has been a common practice for cache libraries on web frameworks to support both the caching strategy and the directives from the decorator. Although clearly that's not needed if the cache is used internally, not for HTTP routes. |
Yes, this library is framework agnostic. However there are some experimental functionality that's comes in 6.3.0 version and not documented yet A
@ceteri I will be happy if you will try to use it, but at your own risk because it not tested much yet ( but I think that is better then https://github.com/long2ice/fastapi-cache ))) from cashews.contrib.fastapi import CacheRequestControlMiddleware
app = FastAPI()
app.add_middleware(CacheRequestControlMiddleware) |
I'll keep this issue open till I will add documentation about this "contrib" module |
Thank you @Krukov yes, that looks really good. cashews/examples/fastapi_app.py Line 11 in 0b64ec9
Ultimately it might also be helpful to include features that take into account the edge (CDN) cache rules, and how the middleware needs to interact with those. For example, https://developers.cloudflare.com/cache/how-to/cache-rules/ We have not seen any caching libraries focus on the edge or intermediate storage grids used by edge caches. We've built out code to handle this, although it is not generalized in a way that it could be used readily in a framework-agnostic library. |
Tried adding middleware as mentioned in the above comments :
But I am getting this error while starting the server.
|
Hi @shijo-keyvalue - Looks like a bug with python3.7 support , I will take a look at weekends. Also I found a few bugs with |
Added a few words in README (documentation) about contrib module and integrations/tools for an fastapi app @shijo-keyvalue Sorry but I dropped 3.7 support as we don't have CI pipelines for it and it's a very "unpopular" version. |
The async support and client-side caching here look great.
However, from testing, it appears that use of the
@cache
decorator here does not set acache-control
header?Is there any reason that was omitted?
The text was updated successfully, but these errors were encountered: