mvcdonutcaching icon indicating copy to clipboard operation
mvcdonutcaching copied to clipboard

Caching Response Headers

Open LinuxDoku opened this issue 10 years ago • 9 comments

Hello,

is it possible to cache response headers which are set via custom ActionFilter's?

Our application has a ActionFilter which set's the Content-Range header by inspecting the view model. This header get's lost when donut caching is serving the site from cache.

Thank you!

LinuxDoku avatar Sep 08 '14 16:09 LinuxDoku

@LinuxDoku We have a similar problem. We need to update a cookie, but the action is cached, so the cookie doesn't change. How did you solve your problem?

migig avatar May 23 '15 18:05 migig

We have no fix for this yet. ATM we`re sending a timestamp at the end of the url to disable the caching for this request.

Our trainee has implemented correct header caching in mvcdonutcaching but we had no time to code review this feature. He meant it was quite simple to develop - maybe you could give it a try.

LinuxDoku avatar May 23 '15 18:05 LinuxDoku

@LinuxDoku If / once you're comfortable sharing your code, that would be awesome. I'd try! clean it up and submit it as a PR to @moonpyk.

Been digging into the codebase myself, but don't have a clue where to begin.

migig avatar May 23 '15 18:05 migig

@irii could you commit your fix here on github? Thx, will bring some energy to the office on tuesday ;)

LinuxDoku avatar May 23 '15 18:05 LinuxDoku

@LinuxDoku @irii :smiley: :beer:

migig avatar May 23 '15 18:05 migig

@LinuxDoku @migig https://github.com/irii/mvcdonutcaching/commit/a18af56f9da8a0da9bd8689ca684acdb147519be hope it works :smiley:

ghost avatar May 23 '15 20:05 ghost

@irii nice code!

Simply adding the headers to the attribute (in a semicolon separated list) is enough?

[DonutCache(CachedHeaders = "Content-Range;x-cache-item")]

Can't wait to see this in Zion ;)

LinuxDoku avatar May 23 '15 20:05 LinuxDoku

@LinuxDoku @irii Ohhhh, OK, I think I understand what you did, please correct me if I'm wrong.

Your problem was that you are setting headers, but they are excluded from the cache. So your fix allows you to manually specify which headers to cache.

My problem is certain headers ARE cached, and I want them excluded. Specifically, cookies.

Your code is nice and useful though! :smiley:

migig avatar May 23 '15 20:05 migig

Hi, I need to force server for cache a ajax request different than normal request. I used this line of code and it works, but I need an equivalent code for donut. Is it possible? [OutputCache(CacheProfile = "long", Location = System.Web.UI.OutputCacheLocation.Server, VaryByParam = "*", VaryByHeader = "X-Requested-With")]

mahdi87gh avatar Sep 28 '15 11:09 mahdi87gh