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
This commit is contained in:
Lance Edgar 2022-02-10 20:31:03 -06:00
parent e852613567
commit 9584fb57b0

View file

@ -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))
config.add_view(cls, attr='index', route_name=route_prefix,
permission='{}.list'.format(permission_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
http_cache=0)
kwargs['http_cache'] = 0
config.add_view(cls, attr='index', route_name=route_prefix,
permission='{}.list'.format(permission_prefix),
**kwargs)
# download results
# this is the "new" more flexible approach, but we only want to