0

There was a weird issue yesterday about asp.net's outputcaching (webforms). We were using page-level caching (not partial caching) for a multi-lingual site (language is determined via querystring key) and for some purpose, caching stopped working for some languages. I kept track of GetVaryByCustomString method of Global.asax file but, it didnt worked. I will give more details in answer...

Oğuzhan Kahyaoğlu
  • 1,727
  • 2
  • 15
  • 20

2 Answers2

1

Perhaps you need to set the Shareable attribute on your cookies to true?

If a given HttpResponse contains one or more outbound cookies with Shareable is set to false (the default value), output caching will be suppressed for the response. This prevents cookies that contain potentially sensitive information from being cached in the response and sent to multiple clients. To allow a response containing cookies to be cached, configure caching normally for the response, such as using the OutputCache directive or MVC's [OutputCache] attribute, and set all outbound cookies to have Shareable set to true.

https://msdn.microsoft.com/en-us/library/system.web.httpcookie.shareable(v=vs.110).aspx

reZach
  • 8,945
  • 12
  • 51
  • 97
0

Thanks to subversion, i kept track of recent commits. We made a mechanism allowing specific users to view some languages that have not been published yet, using cookies instead of session variables. This was the cause of problem. If a request comes to a language which is not the default language, this mechanism checks whether it should allow user to view page. And IMHO if you modify response's cookie collection, asp.net disables outputcache for that request. I tested it and it really disables cache if you add a cookie to response.

Oğuzhan Kahyaoğlu
  • 1,727
  • 2
  • 15
  • 20
  • Asp.net's outputcache is not a very-well documented module. There are such senarios it might not work. Be careful which event you are using, such as postbacks might not work, cache may not vary and so on... – Oğuzhan Kahyaoğlu Nov 19 '15 at 09:49