Closed Adesoji1 closed 1 year ago
Hello Adesoji,
The nocache middleware is a middleware oriented to avoid the cache in the swagger documentation (a common situation working with Fastapi). Therefore, the enhancement of this PR is not needed now. Also, there are some points to fix:
Thanks so much for your time and effort on this, please keep using the project and supporting like this!
So @AdrianPayne what feature do you want implemented ? 🥺
A good start step could be to cover all the code with unit testing (only 4% is missing). Does this sound good to you?
Description
This pull request extends the NoCacheMiddleware to allow custom caching headers on a per-route basis. It introduces the ExtendedNoCacheMiddleware class, which merges custom caching headers specified in the request scope with default no-cache headers.
Motivation
Previously, caching headers were set globally for all routes. With this enhancement, developers can have fine-grained control over caching behavior.
Testing
To test the changes, I have added unit tests to ensure that the middleware functions correctly. I have also updated the main application to use the ExtendedNoCacheMiddleware for a specific route.
Known Limitations
Fixes #https://github.com/AdrianPayne/fastapi-rocket-boilerplate/issues/10
This pull request resolves the issue #https://github.com/AdrianPayne/fastapi-rocket-boilerplate/issues/10 where custom caching headers were not supported on a per-route basis.
In addition i also added a requirements.txt file using pipreqs python library. my python version is 3.8 and also created the main.py located at app/core/middleware/main.py to show you how to use. the screenshot is attached for you to view the cached route.