Comments (1)
Hello,
It is a pretty new feature - a part of contrib part for fastapi ( obvious )
cache_control_ttl
works only with CacheRequestControlMiddleware
setup. When request comes with Cache-Control
header the value of max-age
stored in context variable and can be used as ttl for cache by cache_control_ttl
.
app = FastAPI()
app.add_middleware(CacheRequestControlMiddleware)
cache.setup(os.environ.get("CACHE_URI", "redis://"))
@app.get("/")
@cache(ttl=cache_control_ttl(default="1m"), key="simple:{user_agent:hash}")
async def simple(user_agent: str = Header("No")):
...
# HTTP GET /
# Cache-Control: private, max-age=300
# Cashews will cache response for 5 min (300 sec)
from cashews.
Related Issues (20)
- CacheEtagMiddleware breaks with redis client_side cache HOT 1
- Counter in Cache condition
- Documenting with sphinx? HOT 1
- ValueError: Duplicated timeseries in CollectorRegistry HOT 2
- early_ttl not working in combination with CacheEtagMiddleware HOT 5
- Gracefully close a connection pool with redis > 5.0.1
- Cannot close Redis connection - AttributeError: 'Redis' object has no attribute '_client' HOT 4
- Cache doesn't work with GZIPMiddleware HOT 5
- JSON serializer HOT 5
- Early cache with sqlalchemy & fastapi depend (sqlalchemy.exc.IllegalStateChangeError: Method 'close()' can't be called here; method '_connection_for_bind()' is already in progress and this would cause an unexpected state change to <SessionTransactionState.CLOSED: 5>) HOT 1
- Formatter Called with Formatted Value HOT 6
- CacheRequestControlMiddleware: Backend not found exception with non-default cache prefix HOT 3
- cache_control_ttl can't be used directly with cache api HOT 1
- thunder_protection with multiple event loops breaks HOT 3
- re.error: bad character in group name when using custom formatter in a tag HOT 3
- Unhandled exception when there are only backends with prefixes HOT 1
- Feature: Get or set
- _empty and _empty_in_redis marker objects leak HOT 1
- Redis Client Side Connection Timeout HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cashews.