Mercurial > libervia-web
diff src/server/server.py @ 1019:34240d08f682
pages: HTTP cache headers handling:
when checkCache is used, HTTP headers handling cache are now used:
- ETag is first checked, using a hash of the rendered content
- Last-Modified is used as a fallback is client is not handling ETag
When suitable, a HTTP 304 code (Not Modified) wihtout body is returned instead of the whole page.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Jan 2018 13:14:06 +0100 |
parents | 6b573b4b5bb0 |
children | dc6c8c4d8ff6 |
line wrap: on
line diff
--- a/src/server/server.py Sun Jan 21 13:08:54 2018 +0100 +++ b/src/server/server.py Sun Jan 21 13:14:06 2018 +0100 @@ -1909,6 +1909,15 @@ def registerWSToken(self, token, page, request): websockets.LiberviaPageWSProtocol.registerToken(token, page, request) + ## Various utils ## + + def getHTTPDate(self, timestamp=None): + now = time.gmtime(timestamp) + fmt_date = u"{day_name}, %d {month_name} %Y %H:%M:%S GMT".format( + day_name = C.HTTP_DAYS[now.tm_wday], + month_name = C.HTTP_MONTH[now.tm_mon-1]) + return time.strftime(fmt_date, now) + ## TLS related methods ## def _TLSOptionsCheck(self):