ImageResizer autoclean - imageresizer

I am trying to decrease ImageResizer [IR] cache size. IR are behind the CDN and for now it take about 2 days to grow up disk cache to 200Gb.
I found that there is autoclean parameter for DiskCache plugin. I enable it on my pre-prod but it did not affect to the cache. I measure count of files after enabling autoclean:
Yesteday, 03:53pm
files 5944
folders 2153
Yesteday, 07:10pm
files 5980
folders 2199
Today, 11:54am
files 6382
folders 2674
What's I am doing wrong?
Here is my Web.config:
<resizer>
<plugins>
<add name="S3Reader2" prefix="~/s3" region="eu-west-1" XXX reducted XXX cacheMetadata="false" checkForModifiedFiles="true" cacheUnmodifiedFiles="true" />
<add name="SimpleFilters" />
<add name="AdvancedFilters" />
<add name="DiskCache" />
<add name="PdfRenderer" downloadNativeDependencies="true" />
</plugins>
<diskcache autoclean="true" CleanupStrategy="14400"/>
<licenses>
<license>
***reducted****
</license>
</licenses>
</resizer>

See https://imageresizing.net/docs/v4/plugins/diskcache
The v4 disk cache limits the quantity, not size of files. You can limit the quantity via the subfolders="" setting, which must be a power of two. Roughly 400 files are permitted per subfolder.
<diskcache autoclean="true" subfolders="256"/>

Related

ImageResizer works when testing with Visual Studio - not working on production?

I have ImageResizer installed via NuGet which is working fine when I run the ASP.Net MVC website from Visual Studio. I can get to the /resizer.debug page and it says all is well.
When I come to publish the site from Visual Studio to the main IIS instance on the same machine, ImageResizer does not work and when I browse to /resizer.debug I get a 404 Not Found error.
I have published the web.config and verified all the image resizer components are in there. Eg:
<httpModules><add name="ImageResizingModule" type="ImageResizer.InterceptModule" /></httpModules></system.web>
The ImageResizer dlls are also in the /bin directory.
However, nothing is happening and the debug page will not display.
Is there something that needs to be done to configure ImageResizer on IIS7 when publishing the project?
It appears that you only configured it for IIS Classic, not IIS7 Integrated mode. There must be a <system.webServer> element with the module installed.
From the installation guide:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection,ImageResizer" requirePermission="false" />
</configSections>
<resizer>
<!-- Unless you (a) use Integrated mode, or (b) map all requests to ASP.NET,
you'll need to add .ashx to your image URLs: image.jpg.ashx?width=200&height=20 -->
<pipeline fakeExtensions=".ashx" defaultCommands="autorotate.default=true"/>
<plugins>
<add name="DiskCache" />
<!-- <add name="PrettyGifs" /> -->
<!-- <add name="SimpleFilters" /> -->
<!-- <add name="S3Reader" /> -->
</plugins>
</resizer>
<system.web>
<httpModules>
<!-- This is for IIS7/8 Classic Mode and Cassini-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<!-- This is for IIS7/8 Integrated mode -->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
</modules>
</system.webServer>
</configuration>

How to publish an MVC 6 website in IIS with multiple apps in the src folder

When I try to publish an asp.net 5 website with multiple web apps in the 'src' folder. It works okay in klr but If I run it under IIS, I get this error:
Failed to resolve the following dependencies for target framework 'Asp.Net,Version=v5.0'
Here is a very basic simple project attached that you might want to run under IIS.
http://www.filedropper.com/iissampleapp
Update: updating my question as requested.
In the attached project, I just right click on "IISSampleApp" and click publish. Visual studio creates files on local file system, which I then try to run under IIS. After publish, both of the web apps reside under src folder as src\IISSampleApp and src\SubApp. The IISSampleApp is the main app that should run as website, and it just references a class DateClass from SubApp.
I have created this sample project to get the answer, my actual project have similar structure and I get the same error.
I have uploaded the Precompiled version of the project here: http://www.filedropper.com/precompilediissample
Below is my generated web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta3" />
<add key="runtime-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta3" />
<add key="kre-clr" value="clr" />
<add key="kre-app-base" value="..\approot\src\IISSampleApp" />
</appSettings>
</configuration>
edit the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta3" />
<add key="runtime-path" value="YOUR-RUNTIME-BASE-PATH\.k\runtimes" />
<add key="kre-version" value="1.0.0-beta3" />
<add key="kre-clr" value="clr" />
<add key="kre-app-base" value="..\approot\src\YOURPROJECT" />
</appSettings>
</configuration>
and set the security policy for \approotand \wwwroot
update: updating the answer after question's update
That just can't work like this because the kpm bundle command packages website as website and not as class library and you have 2 Startup class which is no good. If you want to share code between 2 website create a class library.

Precompile not working with Razor views in MVC 4

I'm trying to precompile razor views but during the build VS2010 throws errors such as "#ViewBag does not exist in the current context." The project builds and runs fine when views are not precompiled.
In order to turn on view compilation I set the following node in the project file:
<MvcBuildViews>true</MvcBuildViews>
The section below exists in the Views Web.config file.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Xml"/>
<add namespace="System.Xml.Linq"/>
</namespaces>
</pages>
</system.web.webPages.razor>
Any ideas why the project won't build?
Geeze, do I ever feel like an idiot. Turns out there were some cshtml files in a _temp folder that resided inside of the project folder. Even though the folder was excluded from the solution the compiler was picking up the files contained therein. Moving that _temp file out of the project folder fixed the issue.

Using Imageresizer diskcache with virtualfolder

Im trying to combine the ImageResizer plugins DiskCache and Virtualfolder, becouse I want to save the images to a network path. I have added both plugins in my webconfig:
<resizer>
<plugins>
<add name="MvcRoutingShim" />
<add name="DiskCache" />
<add name="PrettyGifs" />
<add name="SimpleFilters" />
<add name="VirtualFolder" virtualPath="~/" physicalPath="D:\temp\diskcache" vpp="false"/>
</plugins>
<diskCache dir="~/" autoClean="false" hashModifiedDate="true" enabled="true"
subfolders="32" cacheAccessTimeout="15000" />
</resizer>
But I dont understand how I should map the VirtualFolder diskcache dir, to save to the physical path.
Could someone give an example how to save images with diskcash to a network path?
You must use an IIS virtual folder, not an ImageResizer virtual folder. And it can't be the root of the site, it needs to be a subdirectory.

Dotless HttpHandler with VS2013 Preview

I have just installed the Visual Studio 2013 preview and run up my site. I've noticed that the less files which are used in my site are not being correctly transformed to css and are coming down as blank CSS files.
It appears something is going wrong inside the dotless httphandler as when I force minification for the bundle everything works correctly.
web.config
<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
...
<httpHandlers>
<add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
...
<handlers>
<add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
</handlers>
The issue appears to go away if I force minification eg. System.Web.Optimization.BundleTable.EnableOptimizations = false; which suggests something is different in the way it processes the HTTP handler
Try putting handleWebCompression="false" in the configuration for dotless (in the web config)
<dotless minifyCss="false" cache="true" web="false" handleWebCompression="false" />