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

  • Home
  • SEARCH
  • 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 8178813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:51:24+00:00 2026-06-06T23:51:24+00:00

I am developing my application in ASP.NET 4.5. I setup a webservice. The webservice

  • 0

I am developing my application in ASP.NET 4.5. I setup a webservice. The webservice get accessed by Jquery using a GET Ajax call. The function has a ‘id’ parameter and for each id it returns different content.

I want to cache that data both on server and client. On client I already know how to use ‘CacheDuration’ but the problem is with the client side. I use HttpFox to get the headers of each response.

I’ve setup the following code at the beginning of the function:

    HttpCachePolicy cache = HttpContext.Current.Response.Cache;
    cache.SetCacheability(HttpCacheability.Private);
    cache.SetExpires(DateTime.Now.AddMinutes((double)10));
    cache.SetMaxAge(new TimeSpan(0, 0, 10));


    FieldInfo maxAgeField = cache.GetType().GetField(
    "_maxAge", BindingFlags.Instance | BindingFlags.NonPublic);
    maxAgeField.SetValue(cache, new TimeSpan(0, 10, 0));

What I want to do is to prevent the client from sending a request again for the same ID, and do that for let’s say.. 10 minutes. So at the first call the request will be made and we get response 200. At the second time the response header should be 304.

Right now the code above doesn’t do that and I want to know how to achieve that. Again, I am talking on client-side caching that return 304, so it want go to the server again for the same ‘id’ until the cache is expired.

I know that it can be done using the code, so please don’t submit IIS type of solutions.

Need your help to solve this.

  • 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-06T23:51:25+00:00Added an answer on June 6, 2026 at 11:51 pm

    You will need to implement the last modified header

    Response.Cache.SetLastModified(lastWriteTime.Value.ToUniversalTime());
    

    This will allow your client to check for last modified values and not refetch.

    You could in theory fake the last modified time to the nearest 10 mins by using

    public static DateTime Round10(this DateTime value)
    {   
        var ticksIn10Mins = TimeSpan.FromMinutes(10).Ticks;
    
        DateTime dtReturn = (value.Ticks % ticksIn10Mins == 0) ? value : new DateTime((value.Ticks / ticksIn15Mins + 1) * ticksIn10Mins);
        if(dtReturn > DateTime.Now())
        {
            return dtReturn.AddMinutes(-10); 
        } else {
            return dtReturn;
        }
    }
    
    
    Response.Cache.SetLastModified(Round10(DateTime.Now);
    

    This code is untested though

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

Sidebar

Related Questions

I am developing an application using Asp.net mvc and jquery. I'd like to use
I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I am currently developing an MVC application in ASP.net. I am using AJAX.ActionLink to
We are developing an application in ASP.Net MVC 3 using jQuery UI Dialog. This
I'm developing an web application using asp.net MVC and jQuery. I have in my
I'm developing an application using ASP.NET 4 MVC 3. I'm using the default AspNetSqlMembershipProvider.
What is difference in developing applications using .Net Framework, Asp.net and developing application in
I'm developing an ASP.NET application for an intranet site that is using Windows/NTLM/WIA/whatever authentication.
We are developing a web application using asp.net and sql server. We are required
I'm developing an application using asp.net mvc, NHibernate and DDD. I have a service

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.