I will explain what I meant.
First of all I needed this system because Google Chart API has some requests-daily CAP so I needed something to bypass it.
The engine was pretty simple.
Consider the vanilla solution: in your HTML you have your img' src directly poiniting to google.
<img src="//google.chart.api?params123">
With a cacher you will not point directly to Google but to your cacher engine:
<img src="//yourwebsite/googleImageCacher.php?id=123">
Now your googleImageCacher.php
is dead simple:
It checks if the image requested is found in a cache (it could be a file or whatever) if it's not present then it will request it to google save it and echo.
Something like: (pseudocode)
$imageAssociation = array( '123' => '//google.chart.api?params123'
'image2' => '//google.chart.api?otherparma' );
if ( file_exists( 'imageCacheDir/' . $_GET['id'] ) ) {
echo file_get_contents('imageCacheDir/' . $_GET['id']);
} else {
//> Request the image to google
//> Save it in the imageCacheDir
//> Print it.
}
Of course you can simplement some expiration time
in your googleImageCacher.php