How can I locally cache pictures from a web-page so it loads faster?

2

I am, on a nearly daily basis, accessing my companies staff directory that is hosted on our wiki. The "problem" (and I use the term loosely) is that when I load the page everybody has a picture associated with their row in the directory.

Is there any way I can cache all the pictures so I don't have to wait for everyone's picture to load?

Ramy

Posted 2013-04-18T13:14:41.310

Reputation: 1 005

1you need to change the cache settings on the server – ratchet freak – 2013-04-18T13:18:59.187

i had a feeling the change had to be made on the server side but i was wondering if there was something i could do on my end. – Ramy – 2013-04-18T14:44:57.860

1I’m not even sure whether this is possible, and if it is, it will be awkward –– but can you write a script to wget the page (HTML only; no embedded objects), strip out the IMG tags, and display it?  Alternatively, you could save the page as a complete HTML page, create your own explicit cache of the images, and write your script to redirect the IMG tags to point to those. – Scott – 2013-04-18T21:05:20.277

Answers

4

You can try increasing the size of your local browser's cache. But it may depend largely on the meta tags on the page. For example the page could be set to expire immediately or no-cache (see here for more discussion.

If it is really bugging you could set up a local proxy server. See this post Run a local proxy server for one example of how this could be done.

Brad Patton

Posted 2013-04-18T13:14:41.310

Reputation: 9 939

0

Take a look at using SQUID or VARNISH, bot open source packages, in proxy mode for your site. Set policies to cache images for an extended period, such as 48 hours. You can also apply this caching policy to Style Sheets, JavaScript Files, fonts, etc... You will also likely want to set policy to cache only servers within your internet domain or specific IP addresses to prevent users from downloading and caching content from CNN, FoxNews, or that one developer who you suspect of cruising adult sites from work.

The first person who hits the defined sever will seed the cache. The second and subsequent user will be pulling the cached items from the caching proxy instead of going out across your intranet to hit the Wiki. This should also speed up the Wiki for other users due to the reduced load.

What also should happen in tandem is the administrators of the wiki server should be setting policies on the server which allow for the caching of static content at remote hosts. If this happens then the only policy for caching which would need to be set on Squid or Varnish would be that of hosts, as the caching policy for the server could then be respected.

James Pulley

Posted 2013-04-18T13:14:41.310

Reputation: 221