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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:27:20+00:00 2026-05-27T13:27:20+00:00

I have the following HTML page: sample_page.html: <h1>sample html page</h1> <script type=text/javascript src=sample_page.js/> The

  • 0

I have the following HTML page:

sample_page.html:

<h1>sample html page</h1>
<script type="text/javascript" src="sample_page.js"/>

The sample_page.js is an empty JSfile.

Now try to load it using JQuery AJAX:

$('div').load('sample_page.html', function(){
   alert('loaded');
});

Now if you use Firebug to examine the request, you’ll see that jQuery requests the sample_page.html and the page itself gets cached (http status code 304). However, it strips out the script tags from the HTML file and executes them (probably using $.getScript). The problem is that it appends a time-stamp to the JavaScript file so it is never cached (status 200).

For a single paged application, this means that every-time a user goes to a page, the script file is reloaded again. Is there anyway to fix this issue?

  • 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-27T13:27:21+00:00Added an answer on May 27, 2026 at 1:27 pm

    Apparently, .getScript() does not support the any caching options. Its source code is this:

    getScript: function( url, callback ) {
      return jQuery.get(url, null, callback, "script");
    }
    

    Since it is a convenience wrapper around .get() you could:

    • either modify the global Ajax options via .ajaxSetup() before you call .load(). These settings would also affect .getScript():

      $.ajaxSetup({ cache: true });
      
    • or you could modify getScript() itself:

      $.getScript = function(url, callback){
        $.ajax({
          type: "GET",
          url: url,
          success: callback,
          dataType: "script",
          cache: true
        });
      };  
      

      jQuery will not break from this modification. This code is absolutely equivalent to the original implementation for all intents and purposes, except that caching is enabled by default.

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

Sidebar

Related Questions

I have the following, very simple html page: <html> <head> <script type="text/javascript"> function alertSelection()
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I want to run Dojo/Dijit with the Google CDN: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/dojo/1.3.2/dojo/dojo.xd.js> </script> I've
I have the following simple script on a page <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
I have the following HTML Code <%@ Page Language=C# %> <html> <head> <title></title> </head>
in my html page, I have the following: <div id=rub> Select at least one
I have the following webform: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=TestWebApp.Default %> <!DOCTYPE html
I have the following HTML (note the CSS making the background black and text
I have the following html page: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
What changes do I have to make to the following simple HTML page to

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.