fastapi-cache icon indicating copy to clipboard operation
fastapi-cache copied to clipboard

add `no-cache` to cache exclusion

Open lccmrx opened this issue 2 years ago • 8 comments

added no-cache to cache exclusion on headers on request

lccmrx avatar Aug 23 '21 14:08 lccmrx

@DevLucca In the case of no-cache, after fetching the value from the origin server, wouldn't we want to refresh the cache? This would mean that future requests without the no-cache directives would have the most up-to-date value?

rishabh-bhargava avatar Nov 12 '21 05:11 rishabh-bhargava

@DevLucca be definition:

The no-cache response directive indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server.

I my opinion handling no-cache like no-store is wrong. In case of no-cache I would expect to return 304 if ETag equals if-none-match.

schmocker avatar Mar 01 '22 12:03 schmocker

Any chances to get this merged soon? I think no-cache should be treated just as implemented. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#no-cache_2. When making a request with Cache-Control: no-cache I would expect to bypass the cache and be returned the latest value instead.

muety avatar Aug 08 '22 14:08 muety

Thanks! Please resolve conflicts

long2ice avatar Aug 08 '22 14:08 long2ice

Optionally, a 304 with no content could be returned in case the latest value matches what was given as If-None-Match. But nevertheless, the real function should be executed.

muety avatar Aug 08 '22 14:08 muety

Hi guys!

I'll have a look on what was said.

Just to be sure to what @schmocker brought up, the correct implementation would be the 304 response, when If-none-match?

If so, I'll be trying to implement it on these next days!

Thanks a lot!

lccmrx avatar Aug 08 '22 14:08 lccmrx

Also please update the changelog, thanks!

long2ice avatar Aug 08 '22 14:08 long2ice

Hi guys.

@long2ice, I've updated the changelog.md file.

@muety, I've checked the 304 when If-None-Match and guess that @long2ice has already implemented it.

If there is any more fixes to make, please, let me know!

lccmrx avatar Aug 09 '22 16:08 lccmrx

Hi.

@long2ice, is there anything else to implement here?

Thanks!

lccmrx avatar Oct 09 '22 23:10 lccmrx

Hi @long2ice!

Is there anything else left for doing?

Regards!

lccmrx avatar Oct 31 '22 13:10 lccmrx

Thanks!

long2ice avatar Oct 31 '22 13:10 long2ice