outputcache

can you use output caching in asp.net-mvc based on the parameters of your controller action

北城以北 提交于 2019-12-10 18:53:54
问题 i want to use output caching to avoid hitting my db over and over with the same static query but my controllers have parameters that uniquely define the post. How can i factor in my parameters and still support output caching in asp.net-mvc? 回答1: Check out the VaryByParam property of the OutputCache attribute. [OutputCache(Duration=int.MaxValue, VaryByParam="id")] public ActionResult Details(int id) { } For each unique id value, a unique cache instance will be created. Edit: If your caching

How to supress header Vary:* when using OutputCacheProfiles

╄→гoц情女王★ 提交于 2019-12-10 18:37:43
问题 Using any of the OutputCacheProfiles given below <caching> <outputCacheSettings> <outputCacheProfiles> <clear/> <add name="CachingProfileParamEmpty" duration="87" varyByParam="" location="Any" /> <add name="CachingProfileParamNone" duration="87" varyByParam="None" location="Any" /> <add name="CachingProfileParamStar" duration="87" varyByParam="*" location="Any" /> </outputCacheProfiles> </outputCacheSettings> </caching> header Vary:* is always sent HTTP/1.1 200 OK Server: ASP.NET Development

PHP - Is it good practice to cache MYSQL queries in a txt file?

人盡茶涼 提交于 2019-12-10 15:09:09
问题 I'm building an online shop & trying to improve performance by minimising MYSQL queries. Is it good practice to cache the mysql queries via a txt file and then fetch that instead of the query? This is what I'm doing" A php class takes the sql query as a string does an md5 of it if this is the first time it's run then perform the query on the database get the results in an array serialize the array and store it as md5_Of_Query.txt return either unserialize(file_get_contents(md5_of_Query.txt))

“CacheProfile” in MVC 5

强颜欢笑 提交于 2019-12-10 12:57:42
问题 I am beginner in MVC and I have a project to transform from MVC2 to the latest version of MVC. I read read some books on MVC 4, so I started to understand the main mechanisms. However, when transforming my MVC 2 solution, I have a problem with an attribute: OutputCache . By eg. I have multiple Actions like this (the attributes may vary): [OutputCache(CacheProfile = "ProductImage")] public ActionResult GetImage(Guid elementId, int imgtype) in the Web.Config i have in the "caching

ASP.NET OutputCache and Cookies

别说谁变了你拦得住时间么 提交于 2019-12-10 12:56:46
问题 Does anyone know why if is have cookies on my page, the output cache does not work ! Example page <%@ Page Language="VB" AutoEventWireup="false" CodeFile="ct.aspx.vb" Inherits="ct" %> <%@ OutputCache Duration="600" Location="Server" VaryByParam="none" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat=

ASP.net ashx handler not caching

时光毁灭记忆、已成空白 提交于 2019-12-10 11:47:33
问题 We recently installed Robohash as a great fallback for Gravatar: http://static2.scirra.net/avatars/128/5df4bf5d460c9497fdb35578e923ad1f.png As you can see robohashes are hilariously brilliant and served from our static domain. The URL is actually rewritten: <action type="Rewrite" url="gravatar.ashx?hash={R:2}&size={R:1}" appendQueryString="false" /> And in the same web.config file we have the cache profiles: <staticContent> <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT"

Stop EPiServer clearing output cache on publish

 ̄綄美尐妖づ 提交于 2019-12-10 10:05:55
问题 This isn't a question I've seen around, usually it's 'EPiServer isn't clearing the output cache'. I'm trying to achieve the opposite. Each time a page is published the entire cache is dropped and as the client publishes several times a day, this is frustrating. I'm using the [ContentOutputCache] attribute and tried to implement a httpCacheVaryByCustom rule with an accompanying scheduled task in EPiServer to invalidate the cache when we decide to i.e. bundle updates together and invalidate at

OutputCache attribute and jQuery Ajax not caching

天涯浪子 提交于 2019-12-10 08:07:31
问题 I have a simple MVC3 Controller Action like this [HttpGet] [OutputCache(Duration = 1200,Location=System.Web.UI.OutputCacheLocation.Server)] public string GetTheDate() { return DateTime.Now.ToString(); } And I call it from jQuery Ajax like this jQuery.ajax({ type: "GET", url: "http://localhost:60690/Public/GetTheDate", cache: false, success: function (data) { //alert("success"); jQuery("#stats").append("<b>" + data + "</b>"); }, error: function (req, status, error) { alert("failure"); alert

OutputCache VaryByCustom cookie value

≡放荡痞女 提交于 2019-12-08 16:27:33
问题 Is there a way to set the value of an OutputCache based on a cookie value? For simplicities sake, this is my method [OutputCache(Duration = 600, VaryByParam = "None", VaryByCustom = "ztest")] public ViewResult Index() { return View(); } My Global.asax has this (in order to override the GetVaryByCustomString method public override string GetVaryByCustomString(HttpContext context, string custom) { if (custom == "ztest") { HttpCookie ztest = context.Request.Cookies["ztest"]; if (ztest != null) {

ASP.net ashx handler not caching

走远了吗. 提交于 2019-12-08 10:00:33
We recently installed Robohash as a great fallback for Gravatar: http://static2.scirra.net/avatars/128/5df4bf5d460c9497fdb35578e923ad1f.png As you can see robohashes are hilariously brilliant and served from our static domain. The URL is actually rewritten: <action type="Rewrite" url="gravatar.ashx?hash={R:2}&size={R:1}" appendQueryString="false" /> And in the same web.config file we have the cache profiles: <staticContent> <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" /> </staticContent> <caching> <profiles> <add extension=".ashx" policy=