Note that there are some explanatory texts on larger screens.

plurals
  1. POClear Apache cache for a specific image
    primarykey
    data
    text
    <p>I implemented a system to edit images displayed on a website.</p> <p>When an image is edited, I want to display its last version on all pages of the site (where it's called), at least for the user who edited the image.</p> <p>Now I'm searching a better way to clear the cache for a specific image than adding the timestamp to the end :</p> <pre><code>&lt;img src="myimage.jpg?01215654" alt="" /&gt; </code></pre> <p><strong>Why ?</strong></p> <p>It supposes to always add the timestamp at the end of the image path, with a session system for example.</p> <p>But when the session expires (for example, user leaves the site, and go back few hours after), the real path of the image is displayed :</p> <pre><code>&lt;img src="myimage.jpg" alt="" /&gt; </code></pre> <p>And the navigator randomly displays the old image, or the last version... Because Apache cached :</p> <ul> <li>myimage.jpg as the old image</li> <li>myimage.jpg?01215654 as the new version because no one hit it before (was loaded as a new media)</li> </ul> <p><strong>Limitations</strong></p> <ul> <li>I can't change the path of an edited image, for example "myimage.jpg" to "myimage-v2.jpg", which could solve the problem...</li> <li>Images are not served from a controller (not served from a PHP script), they are direclty loaded from their path on the server.</li> <li>I don't want to use a session system that add timestamp or version string at the end of an image path with JS.</li> </ul> <p><strong>What I want</strong></p> <p>I want to say that the cache of "myimage.jpg" has expired, and so to display the last version, and then cache it normally, until the next edition. So I would like to load the image with "200 status", and not "304 modified" after an edit.</p> <p>Note : when an image is edited, <strong>I reload it with JS (JQuery)</strong> in a hidden div, if you now a way to change cache header ?</p> <p>So what I want is to clear the cache header of a specific image that is edited, taking into account the limitations of my project, so if possible by using cache directives without serving the image from a controller, is it possible ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload