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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:34:28+00:00 2026-05-24T03:34:28+00:00

I make an Ajax request in which I set the response cacheability and last

  • 0

I make an Ajax request in which I set the response cacheability and last modified headers:

if (!String.IsNullOrEmpty(HttpContext.Current.Request.Headers["If-Modified-Since"]))
{
    HttpContext.Current.Response.StatusCode = 304;
    HttpContext.Current.Response.StatusDescription = "Not Modified";
    return null;
}
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
HttpContext.Current.Response.Cache.SetLastModified(DateTime.UtcNow);

This works as expected. The first time I make the Ajax request, I get 200 OK. The second time I get 304 Not Modified.

When I hard refresh in Chrome (Ctrl+F5), I get 200 OK – fantastic!

When I hard refresh in Internet Explorer/Firefox, I get 304 Not Modified. However, every other resource (JS/CSS/HTML/PNG) returns 200 OK.

The reason is because the “If-Not-Modified” header is sent for XMLHttpRequest’s regardless of hard refresh in those browsers. I believe Steve Souders documents it here.

I have tried setting an ETag and conditioning on “If-None-Match” to no avail (it was mentioned in the comments on Steve Souders page).

Has anyone got any gems of wisdom here?

Thanks,
Ben

Update

I could check the “If-Modified-Since” against a stored last modified date. However, hopefully this question will help other SO users who find the header to be set incorrectly.

Update 2

Whilst the request is sent with the “If-Modified-Since” header each time. Internet Explorer won’t even make the request if an expiry isn’t set or is set to a future date. Useless!

Update 3

This might as well be a live blog now. Internet Explorer doesn’t bother making the second request when localhost. Using a real IP or the loopback will work.

  • 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-24T03:34:28+00:00Added an answer on May 24, 2026 at 3:34 am

    Prior to IE10, IE does not apply the Refresh Flags (see http://blogs.msdn.com/b/ieinternals/archive/2010/07/08/technical-information-about-conditional-http-requests-and-the-refresh-button.aspx) to requests that are not made as a part of loading of the document.

    If you want, you can adjust the target URL to contain a nonce to prevent the cached copy from satisfying a future request. Alternatively, you can send max-age=0 to force IE to conditionally revalidate the resource before each reuse.

    As for why the browser reuses a cached resource that didn’t specify a lifetime, please see http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

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

Sidebar

Related Questions

I'm working at an app which would make a POST ajax request to a
I make an AJAX request to see if a sesion variable has been set.
If I make a jquery AJAX request which is succesful I get back my
Simple task like make AJAX request , pass one parameter and return result, can
I use this pseudo-class to make Ajax request to server: function RequestManager(url, params, success,
I make an AJAX request like so using JQuery: $.ajax({ type: GET, url: getvideo.php,
I need to make an AJAX request from a website to a REST web
I am using jQuery to make an AJAX request to a remote endpoint. That
I make an AJAX GET request to a PHP script to compare a value
For some reason when I attempt to make a request to an Ajax.net web

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.