问题
I have a strange issue, whereby when I enable output caching in Orchard CMS and have ImageResizer.net cache plugin enabled, I get duplicated page content (full DOM). Just for reference, I am deploying to Azure Small Reserved instance.
Any ideas how to resolve this - do I need to create a cache profile for output cache not to cache images as this is taken care of by the cache plugin?
Thanks in advance,
Peter
Diagnostic information:
Image resizer diagnostic sheet 2/13/2013 9:07:32 PM
1 Issues detected:
(Warning): To potentially see additional errors here, perform an image resize request.
You are using paid bundles: Performance Bundle
Registered plugins:
ImageResizer.Plugins.Basic.DefaultEncoder
ImageResizer.Plugins.Basic.NoCache
ImageResizer.Plugins.Basic.ClientCache
ImageResizer.Plugins.Basic.Diagnostic
ImageResizer.Plugins.Basic.SizeLimiting
ImageResizer.Plugins.MvcRoutingShim.MvcRoutingShimPlugin
ImageResizer.Plugins.DiskCache.DiskCache
Configuration:
<resizer>
<diagnostics enableFor="allhosts" />
<pipeline fakeExtensions=".ashx" />
<plugins>
<add name="MvcRoutingShim" />
<add name="DiskCache" />
</plugins>
</resizer>
Accepted querystring keys:
quality, format, thumbnail, maxwidth, maxheight, width, height, w, h, scale, stretch, crop, cropxunits, cropyunits, page, bgcolor, rotate, flip, sourceFlip, sFlip, sRotate, borderWidth, borderColor, paddingWidth, paddingColor, ignoreicc, frame, useresizingpipeline, cache, process, margin, anchor, dpi, mode, zoom,
Accepted file extensions:
bmp, gif, exif, png, tif, tiff, tff, jpg, jpeg, jpe, jif, jfif, jfi,
Environment information:
Running Microsoft-IIS/7.5 on Microsoft Windows NT 6.1.7601 Service Pack 1 and CLR 4.0.30319.17929
Trust level: Unrestricted
OS bitness: x86 !! Warning, running as 32-bit on a 64-bit OS(AMD64). This will limit ram usage !!
Executing assembly: D:\Windows\SysWOW64\inetsrv\w3wp.exe
IntegratedPipeline: True
Loaded assemblies:
mscorlib Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Web Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Core Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Configuration Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Xml Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Runtime.Caching Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Microsoft.Build.Utilities.v4.0 Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Web.RegularExpressions Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Microsoft.JScript Assembly: 10.0.0.0 File: 11.0.50709.17929 Info: 11.0.50709.17929
System.Web.WebPages.Deployment Assembly: 2.0.0.0 File: 2.0.20710.0
System.Web.Http.WebHost Assembly: 4.0.0.0 File: 4.0.20710.0
EnvSettings Assembly: 1.0.0.0 File: 7.1.1976.0
System.Web.WebPages Assembly: 2.0.0.0 File: 2.0.20710.0
System.Web.WebPages.Razor Assembly: 2.0.0.0 File: 2.0.20710.0
System.Web.Mvc Assembly: 4.0.0.0 File: 4.0.20710.0
Microsoft.Web.Infrastructure Assembly: 1.0.0.0 File: 1.0.20105.407
App_global.asax Assembly: 0.0.0.0
Orchard.Web Assembly: 1.6.0.0 File: 1.6
Orchard.Framework Assembly: 1.6.0.0 File: 1.6
Autofac Assembly: 2.6.3.862 File: 2.6.3.862
System.ServiceModel.Activation Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.ServiceModel.Internals Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.ServiceModel Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
SMDiagnostics Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Xaml.Hosting Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Web.Extensions Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Orchard.WarmupStarter Assembly: 1.6.0.0 File: 1.6
Microsoft.CSharp Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Xml.Linq Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.ComponentModel.DataAnnotations Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Web.DynamicData Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Autofac.Configuration Assembly: 2.6.3.862 File: 2.6.3.862
Castle.Core Assembly: 1.1.0.0 File: 1.1.0.0 Info: 1.1.0.0
Castle.DynamicProxy2 Assembly: 2.1.0.0 File: 2.1.0.0 Info: 2.1.0.0
ClaySharp Assembly: 1.0.0.0 File: 1.0.0.0
FluentNHibernate Assembly: 1.3.0.733
Iesi.Collections Assembly: 1.0.1.0 File: 3.3.1.4000 Info: 1.0
ImageResizer Assembly: 3.2.4.698 File: 3.2.4.698 Info: 3-2-4 Commit: 4b94e40
ImageResizer.Mvc Assembly: 3.2.4.698 File: 3.2.4.698 Info: 3-2-4 Commit: 4b94e40
ImageResizer.Plugins.DiskCache Assembly: 3.2.4.698 File: 3.2.4.698 Info: 3-2-4 Commit: 4b94e40
log4net Assembly: 1.2.11.0 File: 1.2.11.0 Info: 1.2
MySql.Data Assembly: 6.5.4.0
Newtonsoft.Json Assembly: 4.5.0.0 File: 4.5.8.15203
NHibernate Assembly: 3.3.1.4000 File: 3.3.1.4000 Info: 3.3.1.4000
NHibernate.Linq Assembly: 0.0.0.0
NuGet.Core Assembly: 1.1.0.0
Orchard.Core Assembly: 1.6.0.0 File: 1.6
System.Data.SqlServerCe Assembly: 4.0.0.0 File: 4.0.8482.1 Info: 4.0
System.Net.Http Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Net.Http.Formatting Assembly: 4.0.0.0 File: 4.0.20710.0
System.Web.Helpers Assembly: 2.0.0.0 File: 2.0.20710.0
System.Web.Http Assembly: 4.0.0.0 File: 4.0.20710.0
System.Web.Razor Assembly: 2.0.0.0 File: 2.0.20710.0
System.Web.Abstractions Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Web.Routing Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Data.Linq Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Drawing Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.ComponentModel.Composition Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Anonymously Hosted DynamicMethods Assembly Assembly: 0.0.0.0
System.Runtime.Serialization Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
DynamicProxyGenAssembly2 Assembly: 0.0.0.0
Contrib.ProjectionLayouts Assembly: 0.0.0.0
Orchard.Forms Assembly: 1.6.0.0 File: 1.6
Orchard.Projections Assembly: 1.6.0.0 File: 1.6
Orchard.Alias Assembly: 1.6.0.0 File: 1.6
Orchard.Tokens Assembly: 1.6.0.0 File: 1.6
Orchard.Autoroute Assembly: 1.6.0.0 File: 1.6
Orchard.jQuery Assembly: 1.6.0.0 File: 1.6
Orchard.PublishLater Assembly: 1.6.0.0 File: 1.6
Orchard.Scripting Assembly: 1.6.0.0 File: 1.6
Orchard.Themes Assembly: 1.6.0.0 File: 1.6
Orchard.Widgets Assembly: 1.6.0.0 File: 1.6
Orchard.ContentPicker Assembly: 0.0.0.0
Orchard.Blogs Assembly: 1.6.0.0 File: 1.6
Orchard.Comments Assembly: 1.6.0.0 File: 1.6
Orchard.Disqus Assembly: 0.0.0.0
Orchard.Rules Assembly: 1.6.0.0 File: 1.6
Orchard.Media Assembly: 1.6.0.0 File: 1.6
Orchard.MediaPicker Assembly: 1.6.0.0 File: 1.6
Szmyd.Orchard.Modules.Sharing Assembly: 0.0.0.0
Lucene Assembly: 1.6.0.0 File: 1.6
Orchard.Users Assembly: 1.6.0.0 File: 1.6
System.Web.ApplicationServices Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Orchard.Roles Assembly: 1.6.0.0 File: 1.6
Orchard.ContentTypes Assembly: 1.6.0.0 File: 1.6
Orchard.DesignerTools Assembly: 1.6.0.0 File: 1.6
Orchard.Fields Assembly: 0.0.0.0
Orchard.Indexing Assembly: 1.4.1.0 File: 1.4.1
Orchard.Modules Assembly: 1.6.0.0 File: 1.6
Orchard.Packaging Assembly: 1.6.0.0 File: 1.6
System.Data.Services.Client Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Orchard.Pages Assembly: 1.6.0.0 File: 1.6
Orchard.Recipes Assembly: 1.6.0.0 File: 1.6
Orchard.Search Assembly: 1.6.0.0 File: 1.6
Orchard.Tags Assembly: 1.6.0.0 File: 1.6
Orchard.Warmup Assembly: 1.6.0.0 File: 1.6
SysCache Assembly: 0.0.0.0
TinyMce Assembly: 1.6.0.0 File: 1.6
Vandelay.Industries Assembly: 0.0.0.0
MovieRentalOffers Assembly: 1.0.0.0 File: 1.0.0.0
System.Data Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Transactions Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.EnterpriseServices Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Numerics Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
Microsoft.GeneratedCode Assembly: 1.0.0.0
NHibernate.Caches.SysCache2 Assembly: 3.1.0.4000 File: 3.1.0.4000 Info: 3.1.0.4000
ActionRecordProxyAssembly Assembly: 0.0.0.0
ContentPartDefinitionRecordProxyAssembly Assembly: 0.0.0.0
Lucene.Net Assembly: 2.9.4.1 Info: 2.9.4
System.Web.Mobile Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
System.Xaml Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
PermissionRecordProxyAssembly Assembly: 0.0.0.0
System.Dynamic Assembly: 4.0.0.0 File: 4.0.30319.17929 Info: 4.0.30319.17929
ContentFieldDefinitionRecordProxyAssembly Assembly: 0.0.0.0
DynamicProxyGenAssembly2 Assembly: 0.0.0.0
DynamicProxyGenAssembly2 Assembly: 0.0.0.0
ContentItemRecordProxyAssembly Assembly: 0.0.0.0
App_Web_bjaujelw Assembly: 0.0.0.0
App_Web_3ucixrnn Assembly: 0.0.0.0
DynamicProxyGenAssembly2 Assembly: 0.0.0.0
App_Web_hqpkyqpq Assembly: 0.0.0.0
App_Web_4rtpbaer Assembly: 0.0.0.0
App_Web_hn4szlb4 Assembly: 0.0.0.0
ContentTypeRecordProxyAssembly Assembly: 0.0.0.0
App_Web_fmcezex3 Assembly: 0.0.0.0
App_Web_0wv5slaj Assembly: 0.0.0.0
App_Web_z1olvxy5 Assembly: 0.0.0.0
ProviderPartRecordProxyAssembly Assembly: 0.0.0.0
App_Web_j0ak4epp Assembly: 0.0.0.0
回答1:
This can be reproduced without ImageResizer, using the following HttpModule:
public class BlankModule : IHttpModule {
void IHttpModule.Init(System.Web.HttpApplication context) {
//Having any event handlers registered for this event causes cache duplication during the Filter execution
context.PreSendRequestHeaders -= context_PreSendRequestHeaders;
context.PreSendRequestHeaders += context_PreSendRequestHeaders;
}
void IHttpModule.Dispose() { }
protected void context_PreSendRequestHeaders(object sender, EventArgs e) {}
}
Make sure you register it in Web.Config:
<system.webServer>
<modules>
<add name="BlankModule" type="BlankModule"/>
</modules>
</system.webServer>
Register another copy of the module, and you'll get tripled responses, not just doubled.
This is not necccessarily a bug in Orchard.Cache.Contrib; it's more likely a bug in the way ASP.NET handles PreSendRequestHeaders in combination with buffered response filters.
Unfortunately, there's no easy workaround from the ImageResizer side, as ImageResizer needs to be able to set the correct mime-type for an IIS-served file, which means PreSendRequestHeaders.
Bug reports:
- ASP.NET: https://aspnet.codeplex.com/workitem/10347
- Orchard Contrib.Cache: https://orchardcache.codeplex.com/workitem/26
回答2:
Orchard 1.7 and new OutputCache module solves this problem. You can view it here: https://orchardcache.codeplex.com/workitem/26
来源:https://stackoverflow.com/questions/14777337/imageresizer-net-with-cache-plugin-causing-duplicate-output-cache