WebOptimizer icon indicating copy to clipboard operation
WebOptimizer copied to clipboard

EnableDiskCache = false still save to disk

Open DavidJoyal opened this issue 6 years ago • 7 comments

When I tried to disabled the cache to disk, by adding this to my appsettings.json "webOptimizer": { "enableDiskCache": false } the class AssetResponse still try to save it on the disk.

I think the error come from the class AssetBuilder in the function BuildAsync on the line: await _assetResponseCache.AddAsync(asset.Route, cacheKey, response).ConfigureAwait(false);

I think it should be if (options.EnableDiskCache == true) { await _assetResponseCache.AddAsync(asset.Route, cacheKey, response).ConfigureAwait(false); }

Any chance you can add this line or correct this bug in an other way?

In my case, the css and js return a 500 error because my user does not have the right to create the folder and the file

Here is the error (I removed the path on my disk) System.UnauthorizedAccessException: Access to the path '**custom path**' is denied. at System.IO.FileSystem.CreateDirectory(String fullPath) at System.IO.Directory.CreateDirectory(String path) at WebOptimizer.AssetResponseStore.AddAsync(String bucket, String cachekey, AssetResponse assetResponse) at WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options) at WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options) at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext]

DavidJoyal avatar Nov 15 '18 13:11 DavidJoyal

Any chance you correct this @madskristensen ?

Also pinged @hellfirehd because I think he was the one who added this fonctionality?

DavidJoyal avatar Nov 20 '18 21:11 DavidJoyal

That looks reasonable. Send a pull request and it will probably get accepted sooner. I’m running off a fork because I think this project is abandoned/dead.

hellfirehd avatar Nov 21 '18 02:11 hellfirehd

Alright, I just did that. I hope I did it right

Thank you

DavidJoyal avatar Nov 21 '18 13:11 DavidJoyal

Is it possible to approve this merge? We're using the Azure run from package feature, that creates a readonly wwwroot content directory. All the first call to WebOptimizer fail (disk caching is disabled) because it's not allowed to create the directory.

peterbomers avatar Jan 15 '19 18:01 peterbomers

Can someone please approve this merge ?

slaneyrw avatar Nov 11 '19 04:11 slaneyrw

Done

madskristensen avatar Nov 11 '19 16:11 madskristensen

Is there going to be a new release with this fix... the latest public package still contains the bug.

... or do I need to fork this project coz it's dead

slaneyrw avatar May 19 '20 09:05 slaneyrw