Jump to content

Is it possible to force an browser to cache a php image?


RottNKorpse

Recommended Posts

Ok here is what I am wanting to do: Host an image on Photobucket, Use PHP to generate the image with a url as if it is being hosted on my site and cache the php generated image for faster loading later.

 

I am currently using a photobucket account to host my images so the original file I want to cache is actually at the following URL:

http://i87.photobucket.com/albums/k126/WrestleMation/Brain_Rush_S01E01_DotNXT_DSR_XviD-E.gif

 

I am wanting to display the image with a URL from my site so that it doesn't show the fact that it is on a photobucket account.

http://wrestlemation.com/fa_Brain_Rush_S01E01_DotNXT_DSR_XviD-E.gif

 

As you can tell the image from the second link is being generated to pretty much pull in information from the first one and the displaying of the first one under the new URL works just fine.

 

To do what I've done, I used .htaccess rewriting to make the php image generation to use a standard image format url.

 

The php I used to generate the php image is...

//Get dynamic filename from rewritten url. --- which would be : Brain_Rush_S01E01_DotNXT_DSR_XviD-E
$gif_file = "http://i87.photobucket.com/albums/k126/WrestleMation/".$_GET['file'].".gif";

//Load the image
    header("Content-Type: image/gif");
    echo readfile($gif_file);
    die();

 

Ok so the image is generated just fine with my code but the problem is that it has to reload and redownload the image every time the browser is refreshed. Is there anyway I could force all browsers to cache the php generated image so when the generated url is called the next time it pulls from cache instead of pulling from the photobucket account?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.