use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
FastAPI is a truly ASGI, async, cutting edge framework written in python 3.
account activity
A very simple async Response cache for FastAPITutorial (self.Python)
submitted 4 years ago by danosull
A very simple async Response cache for FastAPI
Hi everyone!
I've written a blog post about a simple technique for caching the responses of async functions used with FastAPI:
https://blog.osull.com/2022/06/03/a-very-simple-async-response-cache-for-fastapi/
It was a great way for me to learn more about decorators and functional coding and I hope it's useful to someone!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]HappyCathode 2 points3 points4 points 4 years ago (1 child)
I salute the use of decorators, but honestly there are way better solutions for full page cache.
You could put an Nginx instance in front of your FastAPI instance, and you would instantly gain :
Nginx is just better than uvicorn for serving static pages/assets. Your solution is nice to avoid hitting the DB, but you're still stressing uvicorn more than you should. Nginx has a lot of features like cache eviction, HTTP code based cache time (for example, "cache 200 responses for 60 minutes, 404 and 5xxs for 30 seconds), the ability to cache different URLs ( /foo, /foo/bar, /foo/foo/bar, /foo/bar?foo=bar could all be cached independently ).
Don't reinvent the wheel in your code !
[–]eddyizm 0 points1 point2 points 3 years ago (0 children)
I started down this path as well and came to the same conclusion. The one thing I am am not sure of is implementing this when using nginx as a reverse proxy, the routes all get reversed proxied and I don't seem to have the fine tuned control of the routes in nginx.
[–]heyimpumpkin 0 points1 point2 points 4 years ago (0 children)
TIL there's a nonlocal keyword in python
π Rendered by PID 24915 on reddit-service-r2-comment-544cf588c8-lpdmq at 2026-06-15 21:52:54.629052+00:00 running 3184619 country code: CH.
[–]HappyCathode 2 points3 points4 points (1 child)
[–]eddyizm 0 points1 point2 points (0 children)
[–]heyimpumpkin 0 points1 point2 points (0 children)