eventh-blog
eventh-blog
Eventh
2 posts
Don't wanna be here? Send us removal request.
eventh-blog · 13 years ago
Text
Add memcache to Syte hosted on Heroku
[Syte](http://rigoneri.github.com/syte/) is a simple but powerful packaged personal site with social integrations. Memcache is a key/value store used for caching. There are two Heroku memcache addons: [Memcache](https://devcenter.heroku.com/articles/memcache) and [MemCachier](https://devcenter.heroku.com/articles/memcachier). Both have a free to use level which is sufficient for Syte. Start by adding the addon to your Heroku app: > heroku addons:add memcachier:dev Then either A, pull the necessary changes from [my Syte fork](https://github.com/eventh/syte/tree/heroku-memcache): > git pull git://github.com/eventh/syte.git heroku-memcache Or B, follow these three simple steps to modify your Syte installation: 1. Add *pylibmc==1.2.3* and *django-pylibmc-sasl==0.2.4* to *requirements.txt* 2. Add the following configuration to the bottom of the syte/settings.py file: # Heroku memcachier addon, cache configuration os.environ['MEMCACHE_SERVERS'] = os.environ.get('MEMCACHIER_SERVERS', '') os.environ['MEMCACHE_USERNAME'] = os.environ.get('MEMCACHIER_USERNAME', '') os.environ['MEMCACHE_PASSWORD'] = os.environ.get('MEMCACHIER_PASSWORD', '') if DEPLOYMENT_MODE == 'dev': CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } } else: CACHES = { 'default': { 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache', 'LOCATION': os.environ.get('MEMCACHIER_SERVERS', ''), 'BINARY': True, } } 3. Add cache middlewares to *MIDDLEWARE_CLASSES* in syte/settings.py, such that 'django.middleware.cache.UpdateCacheMiddleware' comes first, and 'django.middleware.cache.FetchFromCacheMiddleware' comes last. Your MIDDLEWARE_CLASSES should now look like this: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.gzip.GZipMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware', ) After you push these changes to Heroku, all Syte pages will be cached for 10 minutes by memcache. The cache time can be changed with the CACHE_MIDDLEWARE_SECONDS setting. In my heroku-memcache branch I've also added never_cache decorator to error pages, see: https://github.com/eventh/syte/blob/heroku-memcache/syte/views/home.py
1 note · View note
eventh-blog · 13 years ago
Text
Hello world!
I have set up this page to have a place to do some blogging. I intend to write some blogs to get some publicity for the [Haskell-Python](http://bitbucket.org/cfbolz/haskell-python) project. Haskell-Python is an attempt to implement Haskell with RPython, to see if purely functional and lazy languages, e.g. Haskell, can benefit from just-in-time compilation. This site is created with [Syte](http://rigoneri.github.com/syte/), but I have added everything except the GitHub page. These can be found as the following branches on [my Syte fork](https://github.com/eventh/syte): * Projects page: [ohloh-integration](http://github.com/eventh/syte/tree/ohloh-integration) * Bitbucket page: [bitbucket](http://github.com/eventh/syte/tree/bitbucket) (merged upstream) * Documents page: [documents](http://github.com/eventh/syte/tree/documents) * About page: [about-page](http://github.com/eventh/syte/tree/about-page) I have modified Syte to enable memcache and serve static content from Amazon S3. In the near future I might write a blog post explaining how you can do so yourself. Any other changes I have made to Syte can be found in the [eventh branch](http://github.com/eventh/syte/tree/eventh).
0 notes