This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

WSGI caching middleware.

PageCache is a WSGI middleware that can be used to cache complete responses from WSGI applications. PageCache works well with memcached but can be used with other caching backends as well.

PageCache has not been widely tested, use with caution.

Usage

Here’s a simple example to get you started:

from pagecache import PageCacheMiddleware

app = ...
cache = memcache.Client(...)
cached_urls = (('/foo', 30, 120), # url prefix, TTL, grace period
               ('/bar', 3600, 60))
app = PageCacheMiddleware(app, cached_urls, cache)

Cached urls

The list of urls to cache is given in the cached_urls list (or tuple). Each entry of this list is a tuple in the following format: (<url prefix>, <TTL in seconds>, <grace period in seconds>)

Pages are served from the cache in the TTL period. When the TTL period has expired the grace period begins. The first request coming in in the grace period will recalculate the page and store the new result in the cache. While the new result is being calculated stale results are served from the cache (until the grace period expires). This is to protect against the dog-pile effect

The cache object

PageCache was only tested with memcached, but it may work with other cache backends as well. The only requirement is that the cache object should have the following methods with reasonably similar semantics as in memcached: get, set, delete, add

A note on cookies

All Set-Cookie headers returned by the application will be ignored. Also, depending on your application you’ll most probably want to make sure that the application doesn’t use any incoming cookie information to calculate responses that will be cached.

Install

You can install the latest version from the github repository:

git clone git://github.com/abiczo/pagecache.git
cd pagecache
python setup.py install

TODO

  • more unit testing
  • better syntax for the cached urls configuration
  • regexp based url matching
  • configurable cache keys (so that multiple applications can use the same memcached instance without having to worry about having the same cached urls)
  • configurable request charset

Patches / pull-requests are welcome.

Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pagecache-0.1.1.tar.gz (4.4 kB) Copy SHA256 Checksum SHA256 Source Aug 13, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting