StaticFileHandler支持的VirtualPathProvider提供的内容缓存 [英] StaticFileHandler that supports caching of VirtualPathProvider served content

查看:148
本文介绍了StaticFileHandler支持的VirtualPathProvider提供的内容缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有嵌入在装配和项目之间共享可重复使用的部分视图,脚本和图像库。

I have a library of reusable partial views, scripts and images that are embedded in assembly and shared between projects.

一切正常,我已经修改web.config中,使被System.Web.StaticFileHandler送达所有必要的文件类型,但不幸的是,它的Cache-Control提供的所有资源:私人

Everything works fine, I've modified web.config to make all necessary file types to be served by System.Web.StaticFileHandler, but unfortunately, it serves all resources with Cache-Control: private.

我可以写我自己的StaticFileHandler这将有助于VPP含量的Cache-Control:公共和到期日期

I can write my own StaticFileHandler that would serve VPP content with Cache-Control: public and expiration date.

我如何使用VirtualPathProvider.GetCacheDependency实现缓存支持?

How do I implement caching support using VirtualPathProvider.GetCacheDependency?

推荐答案

我想通了,为什么会这样。我看着来源为StatisFileHandler。对于嵌入的文件,它不设置任何缓存头。它只做为文件系统中的文件。这意味着将永远不会工作的权利。

I figured out why this happens. I looked at the source for the StatisFileHandler. For embedded files, it doesn't set any of the caching headers. It only does for files in the file system. Meaning this will never work right.

您有两种选择。

1.Find另一个HTTP处理程序。我从来没有使用过这一点,但它已经出现在我的搜索:的https: //$c$c.google.com/p/talifun-web/wiki/StaticFileHandler

1.Find another http handler. I have never used this but it has come up in my searching: https://code.google.com/p/talifun-web/wiki/StaticFileHandler

2.创建一个HTTP模块检查是否使用了统计的文件处理程序,如果是这样设定的高速缓存的信息。

2.Create an http module that checks to see if the statis file handler was used, if so set the caching details.

祝你好运。

这篇关于StaticFileHandler支持的VirtualPathProvider提供的内容缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆