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
https://forums.phpfreaks.com/topic/37515-force-cache-image/
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
https://forums.phpfreaks.com/topic/37515-force-cache-image/#findComment-186157
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.