Opened 7 years ago

Last modified 7 years ago

#4897 defect new

twisted.web server keeps caching headers if an exception is raised

Reported by: ivank Owned by:
Priority: normal Milestone:
Component: web Keywords:
Cc: jknight, ivank Branch:


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.

For example:

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

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:1 Changed 7 years ago by DefaultCC Plugin

Cc: jknight added

comment:2 Changed 7 years ago by ivank

Summary: twisted.web server keeps cache-related headers if an exception is raisedtwisted.web server keeps caching headers if an exception is raised

comment:3 Changed 7 years ago by ivank

Cc: ivank added
Note: See TracTickets for help on using tickets.