Skip to content

Option for disk-backed cache #2626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aspnet-hello opened this issue Jan 2, 2018 · 4 comments
Closed

Option for disk-backed cache #2626

aspnet-hello opened this issue Jan 2, 2018 · 4 comments
Labels
affected-very-few This issue impacts very few customers area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-response-caching severity-nice-to-have This label is used by an internal tool
Milestone

Comments

@aspnet-hello
Copy link

From @benaadams on Saturday, July 2, 2016 8:31:47 PM

So when items are evicted due to memory pressure or over recycles they can be resurrected if needed without regeneration if within cache period.

Similar to Using Static Content Generation in ASP.NET Core by @MaximRouiller

Copied from original issue: aspnet/ResponseCaching#8

@speige
Copy link
Contributor

speige commented Feb 14, 2018

+1

@speige
Copy link
Contributor

speige commented Feb 15, 2018

This can be done by creating a custom class which implements IResponseCache and injecting it with the following code (uses reflection):

  public class CustomResponseCachingMiddleware : ResponseCachingMiddleware
  {
    public CustomResponseCachingMiddleware(RequestDelegate next, IOptions<ResponseCachingOptions> options, ILoggerFactory loggerFactory, IResponseCachingPolicyProvider policyProvider, IResponseCachingKeyProvider keyProvider) : base(next, options, loggerFactory, policyProvider, keyProvider)
    {
      FieldInfo cacheFieldInfo = typeof(ResponseCachingMiddleware).GetField("_cache", BindingFlags.NonPublic | BindingFlags.Instance);

      cacheFieldInfo.SetValue(this, new MyCustomCache());
    }
  }

  //app.UseResponseCaching();
  app.UseMiddleware<CustomResponseCachingMiddleware>();

@speige
Copy link
Contributor

speige commented Feb 16, 2018

I've created a repo for custom cache implementations. It currently only has a disk-backed memory cache. It also has extensions which make ResponseCaching easily overridable for others who wish to code custom implementations.

License is MIT. Feel free to pull it into the official Microsoft repo.

https://github.com/speige/AspNetCore.ResponseCaching.Extensions
https://www.nuget.org/packages/AspNetCore.ResponseCaching.Extensions

@JunTaoLuo JunTaoLuo added affected-very-few This issue impacts very few customers enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-nice-to-have This label is used by an internal tool labels Nov 9, 2020 — with ASP.NET Core Issue Ranking
@JunTaoLuo
Copy link
Contributor

We're glad to see community contributions on this issue! However, it's unlikely we'll incorporate the implementation here unless there's more demand for this issue.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 16, 2020
@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affected-very-few This issue impacts very few customers area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-response-caching severity-nice-to-have This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

5 participants