Posts

Showing posts from July, 2013

Cookie-less Domain and Static Files versioning with Google App Engine

Cookieless domains are one of the must have optimization when you are serving a lot of static files. The reason is that if you have a cookie in the same domain it sends those cookies in the request headers if you are serving your static files on the same domain. Those build up and unnecessary. If you have your cookie in domain level and using appspot domain for your main domain this won't work. This will also version your files so in your app.yaml you can leave (default_expiration: "30d") all the time. Each deploy will prefix your static urls with different version. Here is how I did it: import os from google.appengine.api import app_identity VERSION_ID = os.environ.get('CURRENT_VERSION_ID', '1.1').split('.') VERSION = VERSION_ID[0] APP_VERSION = int(VERSION_ID[1]) APP_ID = app_identity.get_application_id() IS_DEV = os.environ.get('SERVER_SOFTWARE', 'Development/%s' % VERSION_ID).startswith('Dev') IS_BACKEND = backends.