如何让ASP.Net CompositeScript在浏览器中缓存?

时间:2020-12-30 03:51:49

I have been trying to improve the performance of a web page that references several separate JavaScript files. I found the new CompositeScript feature in .Net 3.5 SP1 that allows you to combine scripts at runtime through the ScriptManager and it works great to reduce the number of hits on our server at page load.

我一直在努力提高引用几个单独的JavaScript文件的网页的性能。我在.Net 3.5 SP1中找到了新的CompositeScript功能,允许您通过ScriptManager在运行时组合脚本,它可以很好地减少页面加载时服务器上的命中数。

But the problem is that the combined script never caches on the client side. From everything I've read so far, it should do that automatically. I don't have anything set to prevent it from caching (other scripts we reference that could not be combined cache fine, as do the ScriptResource.axd files). I even added the following to explicitly enable caching in the web.config:

但问题是组合脚本从不在客户端缓存。从我到目前为止所阅读的所有内容来看,它应该自动完成。我没有任何设置来阻止它缓存(我们引用的其他脚本无法组合缓存,ScriptResource.axd文件也是如此)。我甚至添加了以下内容以在web.config中显式启用缓存:

<system.web.extensions>
    <scripting>
        <scriptResourceHandler enableCompression="true" enableCaching="true"/>
    </scripting>
</system.web.extensions>

But it doesn't seem to have an effect.

但它似乎没有效果。

Has anyone seen this problem or have some suggestions on things I can try to fix it?

有没有人见过这个问题,或者对我可以尝试解决的问题有一些建议?

1 个解决方案

#1


-1  

Is debug mode on anywhere? Make sure your webserver's Machine.Config has Retail="True"

调试模式在哪里?确保您的网络服务器的Machine.Config具有Retail =“True”

<configuration>
    <system.web>
        <deployment retail="true"/>
    </system.web>
</configuration>

#1


-1  

Is debug mode on anywhere? Make sure your webserver's Machine.Config has Retail="True"

调试模式在哪里?确保您的网络服务器的Machine.Config具有Retail =“True”

<configuration>
    <system.web>
        <deployment retail="true"/>
    </system.web>
</configuration>