Caching Dynamic Image in PHP

89 views Asked by At

i have two things to complete in my project, First thing is to hide the image path,That is done using dynamically loading the image (imageJPEG) from imageConvert.php with the parameters,The Second thing is i need to implement client side browser caching, For this i was using the

<link rel='subresource'> 

before ( with normal image path ) , but it is not working with dynamic image loading. Do anybody have solution for this.

echo "<img class='lazy' src='imageConvert.php?raw=$image&cap=ps&hash=$user_id' />";
echo '<link rel="subresource" href="imageConvert.php?raw=$image&cap=ps&hash=$user_id" as="image">'; 

Thanks in advance.

1

There are 1 answers

1
William Carneiro On

Your image will not be cached by the browser because, as you know, it's a dynamic image being printed by a php script file.

PHP outputs cannot be cached by the browser, so if you wanna hide the image path, try to use a Rewrite condition in your htaccess to change it to another location.