[bugzilla-gnome-org-extensions] Add Expires: headers for proxied content
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] Add Expires: headers for proxied content
- Date: Thu, 20 Nov 2014 22:20:30 +0000 (UTC)
commit 90e53aa04a309bb3573ddb522ffed1e935131e8b
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Sep 27 12:03:38 2009 -0400
Add Expires: headers for proxied content
When running in demo mode, putting Expires: headers on the proxied
content can be useful to reduce load and allow caching in front of
the server; added a 1 month expiry to attachment.cgi (assume immutable)
and a 5 minute expiry to show_bug.cgi.
proxy/splinter_proxy.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/proxy/splinter_proxy.py b/proxy/splinter_proxy.py
index 5910b2e..c15b68a 100755
--- a/proxy/splinter_proxy.py
+++ b/proxy/splinter_proxy.py
@@ -100,6 +100,7 @@ class ProxyHandler(SimpleHTTPRequestHandler):
def relay_response(self, response):
self.send_response(response.status, response.reason)
content = response.read()
+ seen_expires = False
for header, value in response.getheaders():
# BaseHTTPRequestHandler sends the 'Server' and 'Date' headers
# We are handling the "session" with Bugzilla ourselves, so we
@@ -109,7 +110,16 @@ class ProxyHandler(SimpleHTTPRequestHandler):
# Transfer-Encoding to unchunked.
if header.lower() in ('date', 'server', 'set-cookie', 'transfer-encoding', 'content-length'):
continue
+ if header.lower() == 'expires':
+ seen_expires = True
self.send_header(header, value)
+ if not seen_expires and self.command == 'GET':
+ # Assume that attachments are immutable - give them an Expires of a month
+ if self.path.startswith('/attachment.cgi?'):
+ self.send_header('Expires', self.date_time_string(time.time() + 31*24*60*60))
+ # If we are running anonymously, allow bug content to be cached for 5 minutes
+ elif not ('bugzilla_login' in current_config and 'bugzilla_login' in current_config):
+ self.send_header('Expires', self.date_time_string(time.time() + 5*60))
self.send_header('content-length', len(content))
self.end_headers()
self.wfile.write(content)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]