diff --git a/matemat/webserver/httpd.py b/matemat/webserver/httpd.py index aa282e1..e962a8c 100644 --- a/matemat/webserver/httpd.py +++ b/matemat/webserver/httpd.py @@ -10,7 +10,6 @@ from http.server import HTTPServer, BaseHTTPRequestHandler from http.cookies import SimpleCookie from uuid import uuid4 from datetime import datetime, timedelta -from time import localtime import jinja2 @@ -349,10 +348,10 @@ class HttpHandler(BaseHTTPRequestHandler): # Parse the If-Modified-Since header to check whether the browser can reuse cached content datestr: str = self.headers.get('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT') maxage: datetime = datetime.strptime(datestr, '%a, %d %b %Y %H:%M:%S %Z') - # File modification time in LOCAL time + # Get file modification time filestat: int = int(os.path.getmtime(filepath)) - # Create timezone-unaware datetime object and subtract UTC offset - fileage: datetime = datetime.fromtimestamp(filestat) - timedelta(seconds=localtime().tm_gmtoff) + # Create UTC datetime object from mtime + fileage: datetime = datetime.utcfromtimestamp(filestat) # If the file has not been replaced by a newer version than requested by the client, send a 304 response if fileage <= maxage: