mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
Merge branch 'main' into feat/type-hints-covering
# Conflicts: # fastapi_cache/coder.py # fastapi_cache/decorator.py
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import Any, Dict, Union
|
||||
|
||||
import pendulum
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from starlette.templating import _TemplateResponse as TemplateResponse
|
||||
|
||||
CONVERTERS = {
|
||||
"date": lambda x: pendulum.parse(x, exact=True),
|
||||
@@ -60,6 +61,8 @@ class JsonCoder(Coder):
|
||||
class PickleCoder(Coder):
|
||||
@classmethod
|
||||
def encode(cls, value: Any) -> str:
|
||||
if isinstance(value, TemplateResponse):
|
||||
value = value.body
|
||||
return str(pickle.dumps(value))
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -97,7 +97,7 @@ def cache(
|
||||
request: Optional[Request] = copy_kwargs.pop("request", None)
|
||||
response: Optional[Response] = copy_kwargs.pop("response", None)
|
||||
if (
|
||||
request and request.headers.get("Cache-Control") == "no-store"
|
||||
request and request.headers.get("Cache-Control") in ("no-store", "no-cache")
|
||||
) or not FastAPICache.get_enable():
|
||||
return await ensure_async_func(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user