Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a specific way to redirect requests for a specific URL from a browser to a local site or location?e.g. setting a Firewall or some OS rule to redirect a request for the jQuery lib to a location on my machine?

share|improve this question

Try Redirector extension in Firefox.

edit: other option is to set up www proxy server.

share|improve this answer
i am looking for a more OS based solution, something similar to iptables, that way i am not dependent on FF for this feature. – Carl_Platt Sep 28 '10 at 10:54

Here's what I would do:

  1. Open up your hosts file in a text editor.
  2. Add entries at the end of the file that map the domain names you need to
  3. Save the file.
  4. Create the directory structure for your domains that match the paths of the files you want to reference and copy the files there.
  5. In the web server on your local machine, create websites that correspond to the domains you added in step 2 pointing to the folders you created in step 4.

For example, let's say you want to use Google's hosted jQuery, whose path is

  1. You would add a hosts file entry of
  2. You would then create this folder structure: > ajax > libs > jquery > 1.4.2.
  3. You would then copy the jquery.min.js file into the 1.4.2 folder.
  4. After that, you would setup as a website on your local web server, pointing to the folder you created.
share|improve this answer
Nice, but every other request to (for example other version of JQuery, or other js libraries) will also hit localhost. Many sites rely on their CDN. Do you want to mirror whole on your localhost ? – Casual Coder Sep 28 '10 at 15:25
I see what you are both saying. My problem is that i am in a very bandwidth restricted part of the world, but tend to hang out on sites which rely heavily on certain jscript libs. I am looking to host some of the more popular libs (jquery, mootools, prototype etc) locally since even CDNs aren't very effective from here. I will implement Tim's idea, and fiddle around to see what i get. I take it that it isn't possible to have an entry of type is it? – Carl_Platt Sep 28 '10 at 16:28
@Carl_Platt: Yes, adding the suggested line would point to localhost/ajax/jquery/1.4.2/jquery.min.js See how the hosts files work? Just the domain itself is entered, the folders and files underneath that domain aren't. So, install XAMPP or similar, and on your local machine in the server root for the web server, have the structure match that of the Google API URL: (ajax/libs/jquery/1.4.2/) and put "jquery.min.js" there. – Mistiry Sep 28 '10 at 17:25

Considering your question and your comments, you seem to want to reduce bandwidth usage by blocking or caching some web pages and components.

There are Firefox extensions that may help you. In particular Adblock is a generic mechanism for blocking some URLs, and Adblock Plus comes with a list of ad sites to block. Another one is FlashBlock, which delays the loading of flash content until you request it.

Then you should use a web caching proxy. Wwwoffle in particular was designed specifically with dial-up users in mind. Its name comes from its offline mode (serving cached pages only). It also has options to fine-tune how long things should be kept in cache. In particular you can tell it to trust the cache for longer than the site says it's valid (which is perfectly fine in most cases, occasionally means you need to reload pages explicitly, and plain doesn't work with a few sites of dubious design).

You will probably also benefit from a DNS caching proxy (DNS doesn't use much bandwidth but introduces latency). Pdnsd keeps a cache on disk, even when offline (it's a bit like wwwoffle for DNS). Dnsmasq is another possibility.

share|improve this answer
Just a heads up that the “Wwwoffle” link is down and out. // 6 years later, this can surely happen. ;) – e-sushi Jan 20 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .