Tag Archive for 'cache'

mod_rewrite Google’s proxy cache

A few days ago I wrote about how to configure Wordpress to use Google’s cache proxy servers to serve images. After writing that entry I kept thinking to myself that there had to be a better/easier way to accomplish this other than changing Wordpress settings. Well I finally figured it out and got it working on my other blog DavidChiu.net. It involves using mod_rewrite and symbolic links. First you need to create a symbolic link to the Wordpress /uploads/ folder. For example:

ln -s wp-content/uploads/ images/cache

Then you just need to modify your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^.*wp-content/uploads(.*) http://gmodules.com/ig/proxy?url=http://davidchiu.net/images/cache$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And voila! All images will now be served by Google’s proxy cache!

Free Alternative CDN?

I’ve spent a lot of time thinking about CDNs (content delivery networks) because of the challenges I’ve been dealing with user submitted photos on a highly trafficked site. Most projects I work on use Akamai with great success, but what about alternatives CDNs for personal projects? What first came to mind was Flickr. I mean why not? Flickr was built to serve photos so why couldn’t Flickr serve as a CDN for images on my site? The next thought that came to mind was Google. Google already caches websites and images, so why not use Google as a CDN? So I did a quick search and found a tutorial of how to write a Google Gadget that will cache images. Sounds perfect! Has anyone implemented this across their site? What are the caveats?

I also found this interesting P2P cache/CDN called Coral that is worth looking into.