Jump to content

Force cache image


Nolongerused3921

Recommended Posts

I'm curious as to the best way to force users to cache images that are downloaded with readfile? Currently I'm using:

 

		header("Pragma: public");
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Cache-Control: private",false);
		header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
		header("Content-Transfer-Encoding: binary");
		header("Content-length: ".filesize($filethumb));
		//header("Content-type: $file[mime]");
		header("Content-Disposition: attachment; filename=$file[name]");
		set_time_limit(0);

		@readfile($filethumb);

 

To make sure they don't cache it... However I don't need this for thumbnails or downloading of files (The files will never change, as they can't be changed... You have to reupload a new ID inorder to change a file)

Link to comment
Share on other sites

Yes I want the user to be forced to cache the image... I'm sucking up a lot of bandwidth by having it non-cacheable, and I realize my code is setup this way... However I can't just take these lines out as a lot of browsers don't cache dynamic images unless they're specifically told to... I want to know how to tell a browser to cache it regardless of the settings.

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.