Author agnosticdev
Recipients agnosticdev, oulenz
Date 2018-03-30.15:54:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522425266.43.0.467229070634.issue33181@psf.upfronthosting.co.za>
In-reply-to
Content
Oliver,

A possible option that would work for both the client side caching and the server would be to pass back a Cache-Control header with a max-age attached when the 301 is returned.

I am thinking something like this:

if os.path.isdir(path):
    parts = urllib.parse.urlsplit(self.path)
    if not parts.path.endswith('/'):
        # redirect browser - doing basically what apache does
        self.send_response(HTTPStatus.MOVED_PERMANENTLY)
        new_parts = (parts[0], parts[1], parts[2] + '/',
                     parts[3], parts[4])
        new_url = urllib.parse.urlunsplit(new_parts)
        self.send_header("Location", new_url)
        self.send_header("Cache-Control", "max-age=600")
        self.end_headers()
        return None
    for index in "index.html", "index.htm":
        index = os.path.join(path, index)
        if os.path.exists(index):
            path = index
            break


Possibly we could even provide some way for the max age to be variable.
Thoughts?
History
Date User Action Args
2018-03-30 15:54:26agnosticdevsetrecipients: + agnosticdev, oulenz
2018-03-30 15:54:26agnosticdevsetmessageid: <1522425266.43.0.467229070634.issue33181@psf.upfronthosting.co.za>
2018-03-30 15:54:26agnosticdevlinkissue33181 messages
2018-03-30 15:54:26agnosticdevcreate