I Use This!

Project Summary

Analyzed 3 days ago. based on code collected 3 days ago.

Welcome to Django-gae-cacheThis project contains Django middleware and Google App Engine application.

MotivationI have few small web application on poor VPS (Virtual Private Server). Because there is everything on single server (Django, MySQL server, static content), I though how to lower server load/save memory/whatever. And this project is a result of my invention.

Using this application, you will save bandwidth, memory and CPU load of your web server, because all static resources will be served with Google App Engine.

Installation InstructionsThese instructions was written for version 1.0.0, but following versions are backward compatible.

Download and installInstall package using distutils:

svn checkout django-gae-cache
cd django-gae-cache
sudo python installUpdate your and add the middleware and installed apps settings:

# Something long and unpredictable
GAE_CACHE_SECRET_KEY = 'qwertyuiop'

# URL of your google app

# Turn on/off GAE cache


)Signup for Google app engine... and download Google SDK to your computer.

Configure GAE applicationGo to PACKAGE_DIR/gae-cache, copy _app.yaml to app.yaml and to In app.yaml, replace YourAppName with name of your Google App Engine application. In, fill SOURCE_URL with name of your site. Also set up SECRET_KEY to the same string, as is settings.GAE_CACHE_SECRET_KEY in your Django application. Also set MEDIA_URL to the same string, as is settings.MEDIA_URL in your Django application. Deploy GAE applicationIn PACKAGE_DIR/gae-cache, run " update ." ( is part of GAE SDK, which you downloaded in 3rd step).

Now visit You should be redirected to your site or see 403 Forbidden (depends on gae-cache configuration). It is OK. Find some existing resource file on your site ( and call them thru appspot: Working? Great! UsageCaching mechanism is working out of the box. Immediately after setting up middleware and GAE application, your HTML pages are searched for hyperlinks to static resources and replaced by URL to the same resource using GAE application. On first call of resource, GAE application downloads static resource from your server and save it into memcache. On next request, resource is loaded from memcache, without request to your web server.

Invalidate cacheSometimes you want to change or delete resource. You can invalidate one specific file or whole GAE cache:

from django_gae_cache import api
a = api.Api()

# or
a.InvalidateAll()That's all! You can use that for example in save()/delete() method of your Resource model.

Memcache principeOn GAE application, resources are stored in memcache structures (there is 10GB free quota on GAE, which is enough for middle-size site). Memcache will free the oldest unused resources, when there application need space for newer resource. It means, we don't care of any advanced cache management, because in memcache are the most useful items at every time...

TODOMy web application is far to GAE quota limits, so GAE cache dont have any fallback mechanism yet. It means, that resources are always redirected to GAE and Django dont care, if GAE application is working (GAE is down or over free quota). If you are near to quota limits, it is good idea to enable billing. In near future, I will add some intelligence to Django middleware, which will be able to decide, if resource should be redirected to GAE or not.

CONCLUSIONLet me know, if you are using this GAE cache in your project!



30 Day Summary

Jun 30 2015 — Jul 30 2015

12 Month Summary

Jul 30 2014 — Jul 30 2015



Be the first to rate this project
Click to add your rating
   Spinner f6ecff617ec2ba7f559e6f535cad9b70a3f91120737535dab4d4548a6c83576c
Review this Project!