QUICK AND DIRTY Origin Pull CDN ALTERNATIVE W/ PHP AND HTACCESS

QUICK AND DIRTY Origin Pull CDN ALTERNATIVE W/ PHP AND HTACCESS

This is my quick and dirty attempt at a dynamic mirror content cache

first .HTACCESS in the root to check if the file exist

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) cacheme.php?url=$1 [R=301, L]

and our cacheme.php file to save the files to the new sever on the fly and server them one last time from the OG server with a 302 . . .

$ogfile = $_GET['url'];

$ogserverurl = 'http://example.com/'$ogfile;

$content = file_get_contents($ogserverurl);
file_put_contents($ogfile, $content);

header("Location: $ogserverurl");

now I can enable the CDN feature in WP Super Cache and use any CHEAP “UNLIMITED BANDWIDTH” host to serve up my images on the FLY ! ! ! !

HOPE THIS WORK . . . FINGERS CROSSED !!!

Advertisements

About freshfitteds

Fresh Fitteds is a blog all about the most exclusive new era fitted hats released on the new. If their fresh and their fitteds you can find em on freshfitteds.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s