From 9584fb57b0cf0fcb4dbdabaa91936bf8cc5a7d04 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 10 Feb 2022 20:31:03 -0600 Subject: [PATCH] Only prevent cache for index pages if so configured there is a performance hit for this, depending on your perspective, so let's make it opt-in only for now --- tailbone/views/master.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 3b7bed2a..bcbb58d3 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -4490,14 +4490,19 @@ class MasterView(View): config.add_tailbone_permission(permission_prefix, '{}.list'.format(permission_prefix), "List / search {}".format(model_title_plural)) config.add_route(route_prefix, '{}/'.format(url_prefix)) + kwargs = {} + if rattail_config.getbool('tailbone', + 'prevent_cache_for_index_views', + default=False): + # hopefully, instruct browser to never cache this page. + # on windows/chrome we are seeing some caching when e.g. + # user applies some filters, then views a record, then + # clicks back button, filters no longer are applied + # cf. https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/viewconfig.html#non-predicate-arguments + kwargs['http_cache'] = 0 config.add_view(cls, attr='index', route_name=route_prefix, permission='{}.list'.format(permission_prefix), - # hopefully, instruct browser to never cache this page. - # on windows/chrome we are seeing some caching when e.g. - # user applies some filters, then views a record, then - # clicks back button, filters no longer are applied - # cf. https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/viewconfig.html#non-predicate-arguments - http_cache=0) + **kwargs) # download results # this is the "new" more flexible approach, but we only want to