面对问题,而试图用缓存的NuGet Combres图像包js文件 [英] Facing issue while trying to Cache images js files using Combres Nuget Package

查看:190
本文介绍了面对问题,而试图用缓存的NuGet Combres图像包js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的菲德勒。

我有一个关于Combres的功能查询。 Url.Combress可以缓存CSS文件。对?如果您从物理位置的CSS文件。我得到404错误?为什么?因为该文件被缓存。因此它不应该被拾起从它的物理位置。相反,它应该从高速缓存拾取。是否正确?

我使用MVC3。我已经安装了的NuGet包combres 软件包管理器控制台

I am using MVC3. I have installed Nuget Package combres in Package Manager Console

Install-Package combres.mvc

下面是我的路由表的证明

下面我有两个文件在我的布局。

<link href=""~/Content/Site.css" type="text/css" />
<script src="~/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>

Combress.xml设置

<combres xmlns='urn:combres'>
  <filters>
    <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />
  </filters>
  <resourceSets url="~/combres.axd"
                defaultDuration="30"
                defaultVersion="auto"
                defaultDebugEnabled="auto"
                defaultIgnorePipelineWhenDebug="true"
                localChangeMonitorInterval="30"
                remoteChangeMonitorInterval="60"
                >
    <resourceSet name="siteCss" type="css">
      <resource path="~/content/Site.css" />
    </resourceSet>
    <resourceSet name="siteJs" type="js">
      <resource path="~/scripts/jquery-1.7.1.min.js" />
    </resourceSet>
  </resourceSets>
</combres>

当我执行下面的路径

http://localhost:2474/Home/About

我想,这是下载每次上述文件。按我的理解,应该combress其缓存永远文件在combres.xml设置中提到的图像/ CSS / JS文件。

I think, it is downloading the above files every time. As per my understanding, combress should Cache the images/css/js file which ever files are mentioned in the combres.xml setting.

推荐答案

您需要以不同的引用文件。由于您使用asp.net MVC的我建议你也安装这个互补的NuGet包

You need to reference the files differently. Since you are using asp.net-mvc I would recommend you also install this complementary nuget package

Install-Package combres.mvc 

然后在你的母版页,或任何你想要的各种资源

And then in your master page, or wherever you want your different resources

@Url.CombresLink("siteCss")
@Url.CombresLink("siteJs")

注意:在添加上述code线。添加 @using Combres.Mvc;在布局页

Note : Before adding the above code lines. Add @using Combres.Mvc; in your layout Page.

这是该标准建议为每文档

请注意,你可能希望有完整的源代码在调试模式下,只有在发布模式,这是对你的ResourceSet的设置结合起来: defaultDebugEnabled =自动

Note that you probably want to have full source in debug mode and only combine in release mode, which is a setting on your resourceSet: defaultDebugEnabled="auto"

有其他方面的考虑,但应该是足够的开始。

There are other considerations but that should be enough to get started.

这篇关于面对问题,而试图用缓存的NuGet Combres图像包js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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