Tell browser not to cache certain pages, by default
main grid/index pages, and any view page which contains a row grid
This commit is contained in:
parent
0ead06106c
commit
85ef73dcb9
|
@ -4485,21 +4485,22 @@ class MasterView(View):
|
||||||
|
|
||||||
config.add_tailbone_permission_group(permission_prefix, model_title_plural, overwrite=False)
|
config.add_tailbone_permission_group(permission_prefix, model_title_plural, overwrite=False)
|
||||||
|
|
||||||
|
# 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. so by default we
|
||||||
|
# instruct browser to never cache certain pages which contain
|
||||||
|
# a grid. at this point only /index and /view
|
||||||
|
# cf. https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/viewconfig.html#non-predicate-arguments
|
||||||
|
prevent_cache = rattail_config.getbool('tailbone',
|
||||||
|
'prevent_cache_for_index_views',
|
||||||
|
default=True)
|
||||||
|
|
||||||
# list/search
|
# list/search
|
||||||
if cls.listable:
|
if cls.listable:
|
||||||
config.add_tailbone_permission(permission_prefix, '{}.list'.format(permission_prefix),
|
config.add_tailbone_permission(permission_prefix, '{}.list'.format(permission_prefix),
|
||||||
"List / search {}".format(model_title_plural))
|
"List / search {}".format(model_title_plural))
|
||||||
config.add_route(route_prefix, '{}/'.format(url_prefix))
|
config.add_route(route_prefix, '{}/'.format(url_prefix))
|
||||||
kwargs = {}
|
kwargs = {'http_cache': 0} if prevent_cache else {}
|
||||||
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,
|
config.add_view(cls, attr='index', route_name=route_prefix,
|
||||||
permission='{}.list'.format(permission_prefix),
|
permission='{}.list'.format(permission_prefix),
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
@ -4667,8 +4668,10 @@ class MasterView(View):
|
||||||
|
|
||||||
# view by record key
|
# view by record key
|
||||||
config.add_route('{}.view'.format(route_prefix), instance_url_prefix)
|
config.add_route('{}.view'.format(route_prefix), instance_url_prefix)
|
||||||
|
kwargs = {'http_cache': 0} if prevent_cache and cls.has_rows else {}
|
||||||
config.add_view(cls, attr='view', route_name='{}.view'.format(route_prefix),
|
config.add_view(cls, attr='view', route_name='{}.view'.format(route_prefix),
|
||||||
permission='{}.view'.format(permission_prefix))
|
permission='{}.view'.format(permission_prefix),
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
# version history
|
# version history
|
||||||
if cls.has_versions and rattail_config and rattail_config.versioning_enabled():
|
if cls.has_versions and rattail_config and rattail_config.versioning_enabled():
|
||||||
|
|
Loading…
Reference in a new issue