def last_modified(self, last_modified): """ Add last-modified information :Parameters: - `last_modified`: Last modification date (UTC) :Types: - `last_modified`: ``datetime.datetime`` """ self.headers.set('Last-Modified', _httputil.make_date(last_modified))
def cache(self, expiry, audience=None): """ Add cache information :Parameters: - `expiry`: Expiry time in seconds from now - `audience`: Caching audience; ``private`` or ``public`` :Types: - `expiry`: ``int`` - `audience`: ``str`` """ expiry = max(0, expiry) self.headers.set('Expires', _httputil.make_date( _datetime.datetime.utcnow() + _datetime.timedelta(seconds=expiry) )) fields = ['max-age=%s' % expiry] if audience in ('private', 'public'): fields.append(audience) self.headers.set('Cache-Control', ', '.join(fields)) if expiry == 0: self.headers.set('Pragma', 'no-cache')