I would like to add a HTTP (or WSGI) cache to my Python web application, for all requests which
- are either
GET
orHEAD
- do not have a cookie called
"session_id"
(known users get specialized, non-cacheable pages) - do not have a cookie called
"_flash"
(this cookie is used to show the user some short messages like "article created successfully", even after a redirect) - if there ar开发者_JAVA技巧e cookies which start with
"__utm"
(created by Google Analytics) they should be ignored (not stored in the cache), but the site should still be cached
If additional common caching directives (like cache-control: private
) or even ETAGS are taken into account it would be nice too, but that is currently not a requirement.
Preferable, I do not want to run any additional piece of software like Squid (but I will use it if there a good reasons to do so), so I will prefer a mod_apache
based solution, or even some kind of memcached
powered WSGI-Middleware; Other solutions are also welcome.
Many thanks,
ChristophI'd recommend checking out varnish. It's going to be a lot faster than any WSGI-Middleware you write/find, and you should be able to do everything you want with it. Here's the tutorial for a taste of it's many features, options: http://www.varnish-cache.org/docs/trunk/tutorial/index.html
精彩评论