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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:23:32+00:00 2026-05-21T17:23:32+00:00

I am trying to enable output caching on all ashx files in my site.

  • 0

I am trying to enable output caching on all ashx files in my site. I’m trying to keep the server from generating the file on each request – NOT trying to tell the browser to cache the file.

I’ve distilled my ashx file down to this simple code:

public class DefaultStyles : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/css";
        StringBuilder styleSheet = new StringBuilder();
        styleSheet.AppendLine(string.Format("/* Generated: {0}, {1} */", DateTime.Now.ToShortDateString(),                                                DateTime.Now.ToLongTimeString()));
        context.Response.Write(styleSheet.ToString());
    }
}

And in my web.config file, i have this:

<system.webserver>
    <caching enabled="true">
      <profiles>
        <add extension=".ashx" policy="CacheForTimePeriod" duration="00:01:00"  />
      </profiles>
    </caching>
</system.webserver>

Still, every request i make to the ashx file generates a new version with the current date and time in it.

What am i doing wrong?

Thanks.

  • 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-21T17:23:33+00:00Added an answer on May 21, 2026 at 5:23 pm

    I was actually doing everything right, just not testing in the right environment. Once i deployed the simple example above on our IIS 7 server, it worked as expected with the code above. It should be noted that this DID NOT work on our IIS 6 server. I had not realized that this was a new feature only available in IIS 7

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

Sidebar

Related Questions

I'm trying to enable .htaccess files on a Ubuntu server I set up. I
I am trying to write an output text file from table. I am not
Right now I'm trying to serve CSS and JS files from a server that
I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
I'm trying to enable dynamic fields in the configuration file for my mapping app,
I am trying to enable foreign key constraint of sqlite database from my php
I'm trying to make a cross compiler with the files from http://crossgcc.rts-software.org/doku.php?id=i386linuxgccformac I'm on
I am trying to enable digests to be sent by the Buddypress group email
I am trying to enable link time optimization in g++. My program compiles fine
I'm trying to enable screenshots of the page a logged in user is currently

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.