def add_static_view(self, name: str, path: str):
"""Include a path in static assets and configures cache busting for it.
This does not only include the static resources in the routing, but sets the default cache busting policy for them in the :term:`production` environment.
See :py:meth:`pyramid.config.Configurator.add_static_view` and :py:meth:`websauna.system.Initializer.add_cache_buster`
"""
# Default value is 0
cache_max_age = self.settings.get("websauna.cache_max_age_seconds")
if cache_max_age:
cache_max_age = int(cache_max_age)
self.config.add_static_view(name, path, cache_max_age=cache_max_age)
# If we have caching... we need cachebusters!
if cache_max_age:
self.config.add_cache_buster(path, CollectedStaticCacheBuster(name, path, self.settings))
self.views[name] = path
评论列表
文章目录