#!/usr/bin/python
+import datetime
import logging
import os
import random
import backend
class IUseImage(BaseHandler):
+ expires = 3600 * 3
+
def write_error(self, status_code, **kwargs):
"""
Select a random image from the errors directory
# Render the image
image = image_cls(self.backend, self, profile).to_string()
- # Save the image to the memcache for 60 minutes
- self.memcached.set(mem_id, image, 3600)
+ # Save the image to the memcache
+ self.memcached.set(mem_id, image, self.expires)
self.set_header("Content-Type", "image/png")
+
+ # Set expiry headers
+ self.set_header("Expires",
+ datetime.datetime.utcnow() + datetime.timedelta(seconds=self.expires))
+ self.set_header("Cache-Control", "public,max-age=%d" % self.expires)
+
self.write(image)