Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1011479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:14:26+00:00 2026-05-16T09:14:26+00:00

I’m a little confused about the granularity offered by the HttpResponse.RemoveOutputCacheItem() call. I’m interested

  • 0

I’m a little confused about the granularity offered by the HttpResponse.RemoveOutputCacheItem() call. I’m interested in performing some output caching on dynamically-generated images, and would like to vary the output cache using at least to paramaters (let’s call them ‘id’ and ‘size’ for argument’s sake).

So, for example:

/Image/User?id=1
/Image/User?id=1&size=1
/Image/User?id=1&size=2

Would be cached seperately.

When a given user changes their picture; I would want to invalidate all output cache items for that user id (regardless of size). This question answers my question about a single particular parameter. But..how would I go about flushing all cached responses for a user without regards to the size param? (Let’s assume I wouldn’t know all of the possible values of ‘size’ ahead of time).

I’d ideally like to do something like:

HttpResponse.RemoveOutputCacheItem("/Image/User?id=1&size=*"); //wishful thinking

Can anyone point me in the right direction?

Edit

@JcMalta proposed a promising solution, however I can’t find an appropriate collection that is exposed for items in the output cache. A viable solution might include an operation similar to what he proposed if this exists somewhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:14:27+00:00Added an answer on May 16, 2026 at 9:14 am

    The output cache has a concept of “cache dependencies” that might be what you’re looking for.

    .NET has a FileCacheDependency which means a cache item is automatically invalidated if a file on disk changes, and an SqlCacheDependency which invalidates objects when data in an MSSQL database changes. You can also write custom cache dependencies.

    HttpResponse has a bunch of methods named Add*Dependency/ies to let you use this.

    For example, if your images were based a file on disk, your handler serving the resized image could say:

    HttpResponse.AddFileDependency(@"C:\images\user" + userId + ".jpg");
    

    This registers a dependency for your response. When your response gets added to the output cache, any dependencies go along with it. When a dependency changes, the cache item is automatically invalidated.

    If your images are based on files or SQL data, this might work for you out of the box.

    You can also use HttpResponse.AddCacheItemDependency to have one cache item dependent on another cache item. If you know your original image URL “/Image/User?id=1” will always be cached, then you could make the resized images depend on the original, and HttpResponse.RemoveOutputCacheItem() on the original will clear all of them. If the original image isn’t always cached (maybe no-one has requested the original, only the thumbnails), then I don’t think this will work.

    The reason the built-in cache dependencies work is that both Windows and SQL Server have built-in APIs to notify changes to files or data. The built-in cache dependencies are wrappers around these. But if neither of these is suitable, your last approach is to implement a similar thing for your own purpose.

    The basic idea (untested) is to subclass CacheDependency, let’s call it PictureCacheDependency.

    You need to set up some sort of listener/observer pattern so that when a user edits their picture, the picture editing code can tell any relevant PictureCacheDependency objects that the picture has changed. When that happens, the PictureCacheDependency should call base.NotifyDependencyChanged, and the framework will take care of the rest.

    You’d probably have the PictureCacheDependency constructor register itself in a static dictionary of events, using the user ID as the key. However you approach it, be sure to override CacheDependency.DependencyDispose to free up any references, otherwise you’ll leak memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.