Skip to content
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

Not cached with postman #352

Open
mfroger opened this issue Dec 6, 2023 · 2 comments
Open

Not cached with postman #352

mfroger opened this issue Dec 6, 2023 · 2 comments

Comments

@mfroger
Copy link

mfroger commented Dec 6, 2023

Hi all,

My cache system is working on browser but not in postman

@app.get("/", include_in_schema=False) @cache(expire=600) async def app_home(request: Request): return {'Domain : %s' % generate_random(20)}

Do you have an idea ?

@Sajadrahimi
Copy link

Sajadrahimi commented Dec 16, 2023

Postman sends no-cache header by default which is not necessarily set on your browser, that is why the response is cached on your browser and not on the postman. You can remove this header in the settings.

You can also remove this check from the cache decorator and write your own to make it work with your needs:

request.headers.get("Cache-Control") in ("no-store", "no-cache")

@Bharat23
Copy link

Bharat23 commented Jan 10, 2024

To add to @Sajadrahimi's comment. Another way you can disable Cache-Control: no-cache set by postman is by simply sending a dummy header eg:

Cache-Control: <some invalid value>

I recommend labeling it as a question and closing this one as it has been answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants