开发者

how to cache a control, js files and css files in .net?

I have a master page, inside that I have a menu controls开发者_如何学运维 and other css, JS files.

Whenever I refresh the page from client, everything is coming from the server.

Now I want to cache those controls and those files as per session.

Is there any setting or programmatic settings there to do it?


You should read up on ASP.Net Caching - there are lots of flexible ways to cache your pages.

However in your case, it sounds like you should just be able to add the OutputCache directive to the top of your page:

<%@ OutputCache Duration="60" VaryByParam="None"%>

Static CSS and JS files should be cached automatically by the browser. If you've embedded them as webresources then the caching directives will help you cache them as well.


There's no problem with JS and other items cached on client.

But yes, there's a concern on dynamic controls as they are not simply compiled and depend on request. And here's an article in Smöråkning blog on how to cache them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜