Giter Club home page Giter Club logo

Comments (7)

DerStimmler avatar DerStimmler commented on August 31, 2024 1

I'm really looking forward to this feature. I'm in the same situation that only several action methods need caching.

My current workaround without the use of a base controller is to set the default configuration for e.g. max-age to 0 when registering the service.
That way the caching headers are still present but don't have any impact:

builder.Services.AddHttpCacheHeaders(
  expirationModelOptions =>
  {
    expirationModelOptions.MaxAge = 0;
    expirationModelOptions.NoStore = true;
    expirationModelOptions.NoTransform = true;
    expirationModelOptions.SharedMaxAge = 0;
    expirationModelOptions.CacheLocation = CacheLocation.Private;
  },
  validationModelOptions =>
  {
    validationModelOptions.NoCache = true;
  });

On action methods that need caching, I override this configuration with corresponding HttpCacheExpiration and HttpCacheValidation attributes.

An explicit feature to ignore caching by default would of course be a much better way.

from httpcacheheaders.

KevinDockx avatar KevinDockx commented on August 31, 2024

Hi Sean,

there isn't at the moment, but I like the suggestion - I'll put it on the list of features to add.

KR,
Kevin

from httpcacheheaders.

SeanFarrow avatar SeanFarrow commented on August 31, 2024

from httpcacheheaders.

SeanFarrow avatar SeanFarrow commented on August 31, 2024

@KevinDockx I have a branch with an implementation of this, would you like a PR?

from httpcacheheaders.

Uli-Armbruster avatar Uli-Armbruster commented on August 31, 2024

I'm looking forward to see this feature implemented as well 👍

from httpcacheheaders.

KevinDockx avatar KevinDockx commented on August 31, 2024

@SeanFarrow : thanks for the PR, I accepted it! I've put some time aside next Tuesday to have a look in some more detail at this & a few other open issues in order to release a new version soon :)

from httpcacheheaders.

KevinDockx avatar KevinDockx commented on August 31, 2024

FYI, I had a look, fixed a small issue (HttpCacheExpiration/Valdation attributes should override the global setting & renamed the option: https://github.com/KevinDockx/HttpCacheHeaders/blob/master/src/Marvin.Cache.Headers/HttpCacheHeadersMiddleware.cs#L117. Next to that all is well, this will be in the next release - I'll release an preview in a few hours. Thanks again!

from httpcacheheaders.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.