#4897 defect new
twisted.web server keeps caching headers if an exception is raised
|Reported by:||ivank||Owned by:|
If a resource sets caching headers but then raises an exception, twisted.web.server serves an error page with the existing caching headers. This may cause the error page to be cached.
def render_GET(self, request): request.responseHeaders.setRawHeaders('cache-control', ['max-age=172800, private']) request.responseHeaders.setRawHeaders('expires', ['Sun, 20 Feb 2011 01:57:40 GMT']) if random.random() < 0.05: # Pretend this is a database failure or something 1/0
In this case, the error page served by twisted.web.server.processingFailed might be cached.
If this problem can be solved by clearing or overriding cache-related headers, twisted.web could help users avoid a non-obvious pitfall. If the right thing to do is to keep the cache-related headers, this behavior should be documented so that users know to catch their own exceptions.
Change History (3)
comment:2 Changed 5 years ago by ivank
- Summary changed from twisted.web server keeps cache-related headers if an exception is raised to twisted.web server keeps caching headers if an exception is raised