I\'m using jquery\'s ajax functions to grab a page fragment and display in a section of a page - this fragment includes html and references to external js files.
The
This solution is less of a hack than Murdoch's solution:
$.ajaxPrefilter('script', function(options) {
    options.cache = true;
});
See http://api.jquery.com/jQuery.ajaxPrefilter/
Force the webserver to serve the script with a expire date in the future.
If you use dataType = "script" as an option for jquery ajax the caching will be disabled by default, see http://docs.jquery.com/Ajax/jQuery.ajax#options, try set it manually to "html".
$.ajax({
  type: "GET",
  url: "test.js",
  dataType: "html" // if not set jquery will guess what type it is and disables caching when matching "script"
});
Looks like jQuerys's evalScript function is messing you up...
Line 543 of jQuery:
function evalScript( i, elem ) {
    if ( elem.src )
        jQuery.ajax({
            url: elem.src,
            async: false,
            dataType: "script"
        });
   else
        jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
   if ( elem.parentNode )
       elem.parentNode.removeChild( elem );
}
Here is the breakdown of what happens: The Main Page's JS calls:
$.ajax({
    url:"frag.htm",
    type:"GET",
    success:callBackFunction
})
and GETs frag.htm which contains something like this:
<html><head><script src="test.js"></script></head><body>Content</body></html>
then your callback function is called which probably looks like this:
function callBackFunction(data){
    $("#ajaxContent").html(data); // <- this is the beginning of your problems...
}
When jQuery's html(data) function is called is "cleans" the HTML by removing any script tags and then calls evalScript on each one. evalScript, as you can see, doesn't specify "cache:true" so when it goes through $.ajax cache is null. When cache is null and the dataType is "script" jQuery sets cache=false.
So, to circumvent this problem try this:
function callBackFunction(data){
    var tempAJAX = $.ajax; // save the original $.ajax
        $.ajax=function(s){ // wrap the old $.ajax so set cache to true...
            s.cache=true;
            tempAJAX(s); // call old $.ajax
        }
        $("#ajaxContent").html(data); // insert the HTML and download the <script>s
        $.ajax = tempAJAX; // reset $.ajax to the original.
    }
}
Before we insert the new HTML from "frag.htm" into the Main Page we intercept all calls to $.ajax, modify the object to include cache=true, and then after the script is loaded insert the HTML.
Let me know if you have any questions.