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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:34:47+00:00 2026-06-16T04:34:47+00:00

I am using the ImageResizing library, to resize and deliver my image in my

  • 0

I am using the ImageResizing library, to resize and deliver my image in my C# Mvc application.

One thing that isn’t happening though is my image aren’t getting cached.

I am struggling to understand what would be required to appropriately add caching for each image.

I just need to know if I am on the write track? Will this cache my images correctly?

I think what I need to do, is set the FinalContentType, and FinalContentType in my ImageResizer_OnPostAuthorizeRequestStart (I dont know where to get these values)

And then, I am hoping that in the Application_PreSendRequestHeaders I can use the code below to set the cache headers correctly.

I have used a modified version of the method described here.

Here is my code:

 private static void ImageResizer_OnPostAuthorizeRequestStart(IHttpModule sender2, HttpContext context)
        {
            string path = Config.Current.Pipeline.PreRewritePath;
            if (!path.StartsWith(PathUtils.ResolveAppRelative("~/s3"), StringComparison.OrdinalIgnoreCase)) return;
        Config.Current.Pipeline.SkipFileTypeCheck = true;
        Config.Current.Pipeline.ModifiedQueryString["cache"] = ServerCacheMode.Always.ToString();
    }

    protected void Application_PreSendRequestHeaders(Object source, EventArgs e)
    {
        var app = source as HttpApplication;

        HttpContext context = (app != null) ? app.Context : null;

        if (context != null && context.Items != null && context.Items["FinalContentType"] != null && context.Items["LastModifiedDate"] != null)
        {
            //Clear previous output 
            //context.Response.Clear(); 
            context.Response.ContentType = context.Items["FinalContentType"].ToString();

            //FinalContentType is set to image/jpeg or whatever the image mime-type is earlier in code. 
            //Add caching headers 
            int mins = 1; //Or Configuration.AppSettings['whatever'] 

            if (mins > 0)
            {
                context.Response.Expires = 1;
            }

            var lastModified = (DateTime?)context.Items["LastModifiedDate"]; //Set earlier in code. 

            if (lastModified != DateTime.MinValue)
            {
                Response.Cache.SetLastModified(lastModified.Value);
            }

            Response.Cache.SetCacheability(context.Request.IsAuthenticated ? HttpCacheability.Private : HttpCacheability.Public);
        }

    }
  • 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-06-16T04:34:48+00:00Added an answer on June 16, 2026 at 4:34 am

    Use the DiskCache and ClientCache plugins to handle disk caching and cache headers respectively.

    ASP.NET output caching is useless here.

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

Sidebar

Related Questions

I want to resize an image with the GDI library so that when I
Using System.Diagnostics.EventLog .NET type one can programmatically create logs into the Event Viewer application.
I'm using ImageResizer.net library for image resizing on a site I've been working on.
Here is the effect that I need: http://www.agilepartners.com/blog/2005/12/07/iphoto-image-resizing-using-javascript/ Is there any jQuery plugin doing
i am using a class written by someone to resize the image and store
We are using the image resizer from imageresizing.net and are seeing some weird behaviour.
I am getting a fatal error from my image resize script that takes jpegs
Using the Exiv2 library to write some exif tags to an image i'm running
I'm using this php class ( http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php ) for creating the different sized images
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain

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.