-
Notifications
You must be signed in to change notification settings - Fork 248
Open
Description
Requests for static resources currently cause a session to be opened, which can be costly as the session expiry date is updated in the storage backend. Consider adding a configuration key to bypass opening sessions for static resources.
A workaround is to use a custom session interface, for example:
class StaticRequestFilteringSessionInterface(SessionInterface):
def __init__(self, app):
self._delegate = app.session_interface
self._exclude_path_prefix = app.static_url_path + "/"
def open_session(self, app, request):
if request.path.startswith(self._exclude_path_prefix):
return self.make_null_session(app)
return self._delegate.open_session(app, request)
def save_session(self, app, session, response):
return self._delegate.save_session(app, session, response)Configured with:
from flask_session import Session
...
Session(app)
app.session_interface = StaticRequestFilteringSessionInterface(app)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels