Msg#: 4026580 posted 2:50 pm on Nov 17, 2009 (gmt 0)
Msg#: 4026580 posted 2:58 pm on Nov 17, 2009 (gmt 0)
There's not any simple way I can think of with with mod_rewrite, because the browser makes the request for the script from the remote site, not through your server...
To do what you are asking I would probably use PHP or some other scripting language to 'check' for the file when the page loads and dynamically switch the URL served to the browser if it's not present or there's an issue.
Msg#: 4026580 posted 3:01 pm on Nov 17, 2009 (gmt 0)
You could write a server-side script in PERL or PHP to do this, if it won't matter that all requests for ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js will be logged as coming from your server instead of from the client.
[clarity] The client-side ajax call would then be modified to go to your server which would then make a request to google, and if that request timed out or otherwise failed, return the local content. [/clarity]
Msg#: 4026580 posted 3:37 pm on Nov 17, 2009 (gmt 0)
Yeah, I was thinking about just putting the request to see if the files was readable on the pages and switching the URL served to the client based on the result, but jdMorgan's way might be better, because you can use the some request for the jQuery script all the time and just switch where the contents of the file are served from based on the result of the attempted connection...
Either way, in PHP I would probably use is_readable() to make the determination and remember if you go with jdMorgan's you will either have to parse JS as php (or whatever scripting language you decide on) or set the jQuery file location as .ext (php, pl, etc.) to get the script to run before the content is delivered.
Msg#: 4026580 posted 10:25 am on Nov 26, 2009 (gmt 0)
Keeping in mind that this rewrite stuff just doesn't seem to agree with me what I am about to say is probably stupid. But why wouldn't this work: (it is sort of in pseudo-code but you get the general idea?)