Forum Moderators: phranque
I have this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
And a "local" file in the relative path: js/jquery.js
I would like the "local" file to be loaded if the "remote" file is unavailable.
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.
[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]
Jim
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.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js$ ^js/jquery.js$
1) RewriteRule cannot 'see' the protocol or domain name -- It looks at only the localized requested URL-path. You'd need to use RewriteConds to examine those other parts of the request.
2) Unless you own and control "googleapis.com", then your code can have no effect, because the query.min.js script is requested by the client (e.g. browser) from that server, not from yours.
Jim