static.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:websauna 作者: websauna 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号