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 6811461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:19:49+00:00 2026-05-26T20:19:49+00:00

Firstly I appreciate that this question could be seen as subjective but I strongly

  • 0

Firstly I appreciate that this question could be seen as subjective but I strongly believe that there should be and probably is a definitive answer to my question.

At work we are currently implementing a strategy for dynamically resizing and serving images using a generic handler and the question of caching has become something of a contentious issue.

In my original implementation the resized image is cached in memory with a cache dependency based on the original image.

e.g

using (MemoryStream ms = new MemoryStream())
{
    imageEditor.Image.Save(ms, imageFormat);
    // Add the file to the cache.
    context.Cache.Insert(key, 
        ms.ToArray(), 
        new System.Web.Caching.CacheDependency(path)
        );
    imageEditor.Dispose();

    // Set the context headers and serve.
    SetHeaders(ms.GetHashCode(), context, responseType);
    context.Response.BinaryWrite(ms.ToArray());
}

This has it’s downsides though.

  1. Every time the Application Pool Worker Process is recycled (every 1740 minutes by default) we’ll lose anything that is in the cache.
  2. If there are a lot of images we could be in danger of overloading the system memory and causing an out of memory exception. (Does IIS prevent this by recycling the App pool if the usage hits a certain level?)

One of my colleagues has suggested that we implement a file caching system instead that saves the resized file and instead serves that file on subsequent requests which should (I don’t know the intricacies of operating system IO caching memory management) reduce memory usage. Whilst this would allow us to persist the resized image across recycles I see a few major problems with that approach:

  1. We cannot track the original file any more so if someone uploads a
    new image of the same name our resized images will be incorrect.
  2. The fileserver becomes polluted over time with thousands of images
  3. Reading a file is slow compared to reading from memory. Especially if you are reading multiple files.

What would be the best overall approach? Is there a standard defined somewhere by Microsoft? The sites we build are generally very busy so we’d really like to get this right and to the best possible standard.

  • 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-26T20:19:50+00:00Added an answer on May 26, 2026 at 8:19 pm

    We have a similar system on my website. Regarding your objections to the file caching system:

    1,2) On my site I have a single class through which all file saving/loading passes. You could implement something similar, that clears all the cached,resized images whenever a user uploads a new image. If you name the files in a predictable manner this isn’t hard to do. If storage space is a concern for you, you could implement something to remove all cached images with a last access date that is too old.

    3) This depends on how your sites work. My site has a vast number of images, so it isn’t feasible to store them all in memory. If your site has fewer images, it might be the better solution.

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

Sidebar

Related Questions

Firstly sorry if this is a common question but I couldn't find anything on
Firstly I realise that this is a familiar question, it seems to pop up
I'm working in AS3, but I guess this could be a general question, so
Firstly apologies if this is a really simple question but Git is absolutely brand
Firstly, I know this [type of] question is frequently asked, so let me preface
Firstly, this is going to sound like homework, but it ain't. Just a problem
This is a bit of a two part question, firstly the SQL string Dim
Firstly, this is for a class so there are limitations on what we can
Firstly, I understand this is a copy of a similar objective C based question,
Firstly not sure if this is the right place for a question like this,

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.