0

ASP.NET MONO MVC4 application is running in apache with mod_mono Pages should cached only in browser or in proxy servers to save server memory.

Browser gets product list from server using header

Request URL:http://example.com/store/Store/Category/ANDRORI?root=1&open=True&total=2.76
Request Method:GET
Status Code:200 OK
Remote Address:1.2.3.4:80

Server returns returns product list page with headers:

HTTP/1.1 200 OK
Date: Wed, 06 Jan 2016 16:52:47 GMT
Server: Apache/2.2.22 (Debian)
X-AspNet-Version: 4.0.30319
Cache-Control: private
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 8668
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8

Chrome Developer Tools page audit wrote warning about this page

The following resources are explicitly non-cacheable. Consider making them cacheable if possible:

and read this page every time. Response contains

Cache-Control: private

so page must me cached in browser. How to fix this so that page can cached in client?

I tried to add controller

[OutputCache(Location = System.Web.UI.OutputCacheLocation.Client, Duration = 20 * 60)]

but in this case page is cached in server and query string parameters are ignored. Same page is sent from server for all query string parameters.

Andrus
  • 26,339
  • 60
  • 204
  • 378
  • did you try using varybyparam? – techspider Jan 06 '16 at 17:42
  • I tried `VaryByParam="*"` and also `OutputCacheLocation.Downstream` but server still caches same page for every url. This is described in http://stackoverflow.com/questions/13120734/how-to-get-fresh-copy-if-outputcachelocation-outputcachelocation-downstream-i. Question here is different, It asks: Why chrome does not cache MVC page ? Maybe some header or `max-age` is missing which can added using AddHeader() in controller. – Andrus Jan 06 '16 at 17:49

0 Answers0