OLD | NEW |
(Empty) | |
| 1 ETAG = '"123abc"' |
| 2 CONTENT_TYPE = "text/plain" |
| 3 CONTENT = "lorem ipsum dolor sit amet" |
| 4 |
| 5 |
| 6 def main(request, response): |
| 7 # let caching kick in if possible (conditional GET) |
| 8 etag = request.headers.get("If-None-Match", None) |
| 9 if etag == ETAG: |
| 10 response.headers.set("X-HTTP-STATUS", 304) |
| 11 response.status = (304, "Not Modified") |
| 12 return "" |
| 13 |
| 14 # cache miss, so respond with the actual content |
| 15 response.status = (200, "OK") |
| 16 response.headers.set("ETag", ETAG) |
| 17 response.headers.set("Content-Type", CONTENT_TYPE) |
| 18 return CONTENT |
OLD | NEW |