This project is read-only.

Output Cache behavior

Topics: Administration, Core, General, Writing modules
Apr 7, 2014 at 7:17 AM
I enabled Output Cache module.
I sent a request to home page of orchard website with Google Chrome. In first request i get fresh copy of page and in next requests i get cached copy of page. But i get fresh copy again if i use Internet Explorer in this time. And last request makes new cached copy.
In other words why there is not shared cached copy of same page for anonymous users?
Now we have some repeated database query because any user evicts cache for other users.
Apr 7, 2014 at 5:17 PM
I would have to check if the user agent is used in the cache key.
Apr 7, 2014 at 6:05 PM
You are right. I found the following lines in Orchard.Web\Modules\Orchard.OutputCache\Filters\OutputCacheFilter.cs
// create a unique cache per browser, in case a Theme is rendered differently (e.g., mobile)
// c.f.
// c.f.

// enabling this would create an entry for each different browser sub-version
// response.Cache.VaryByHeaders.UserAgent = true;
I think that this way can affect caching performance because in most cases we have same responsive theme for all devices. At least we must create an option on setting page?
What is your opinion?
Apr 7, 2014 at 8:11 PM
Also i think creating new cache entry is better than replacing older entry for same url in case of detecting new browser. If any request from another browser evicts cache, There is no cache really.