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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:11:08+00:00 2026-05-17T20:11:08+00:00

I have a page that makes the same JSONP request multiple times in a

  • 0

I have a page that makes the same JSONP request multiple times in a single page load. In most browsers this works fine, but Safari caches the response locally until such time as the page is reloaded. Even when I send back a Cache-Control: no-cache header on the response.

consider the following example code:

var plcbCnt = 0;
var plcb = "plcb" + plcbCnt;
while(window[plcb]){
    plcb = "plcb" + (++plcbCnt);
}

$.ajax({
    "url": "http://myserver.com/echoDate",
    "dataType": 'jsonp',
    "jsonp": "cb",
    "jsonpCallback": plcb,
    "success": function(resp){
        $("#pants").html($("#pants").html() + resp + "<br/>");
    }
});

First request returns:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 28
Content-Type: application/javascript
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=g0zwq2qiaheh4145cudddmjo; path=/
X-Powered-By: ASP.NET
Date: Wed, 20 Oct 2010 18:22:12 GMT

plcb0('634231777326425375');

Subsequent calls serve from the local cache, rather than hitting the server like they should.

You’re probably wondering what that extra part at the beginning is about setting the callback function. I could just use a random number there, right?
Not really. We avoid extra rendering work by caching the entire output, based on the requested URL. So if I change the callback function name on each request, I lose the benefits of the server cache.

Best I can think of is to add a garbage parameter on the request, and make the server cache strip that out of the URL when making the cache key. But I wanted to see if there was a better option first… something about Safari that I don’t know about.

  • 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-17T20:11:08+00:00Added an answer on May 17, 2026 at 8:11 pm

    it seems it happens on IE also, you can set cache to false in the ajax call:

    $.ajax({  
        /*cache: false,*/
        "url": "http://myserver.com/echoDate",
        "dataType": 'jsonp',
        "jsonp": "cb",
        "jsonpCallback": plcb,
        "success": function(resp){
            $("#pants").html($("#pants").html() + resp + "<br/>");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Page that has a single instance of a UserControl that itself
I have a page that is generated which inserts an HTML comment near the
I have a page that uses $(id).show(highlight, {}, 2000); to highlight an element when
I have a page that has an iframe From one of the pages within
I have a page that is hitting a webservice every 5 seconds to update
I have a page that is supposed to launch the Print Preview page onload.
I have a page that contains a user control that is just a personalized
We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a
I have a page that renders slowly. The trip across the net is quick.
I have a page that is using a non-standard font and arial as a

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.