How can PHP be used to prevent browser caching of images?
Browser caching of images can be prevented by adding a unique query string to the image URL. This can be achieved by appending a timestamp or a random string to the image URL using PHP. By doing so, the browser will treat each request for the image as a unique URL, thus preventing caching.
<img src="image.jpg?<?php echo time(); ?>" alt="Image">
Keywords
Related Questions
- Are there any specific considerations to keep in mind when sending HTML emails with PHP?
- In PHP and MySQL integration, what are the common pitfalls to avoid when querying and displaying data from a database?
- How can a PHP developer efficiently locate where a variable is declared or where a function is being called within a project in an IDE environment?