Skip to main content

Clearing image cache when updated with same name

When we update an image but the name remains the same, the browser keeps on showing the old image. This is very confusing for the admin and annoying too. If we use a decaching code, we end up reloading the image from the server on each visit and thus a lot of bandwidth is wasted.

The best solution to this is to use a URL that changes when a image is updated. The best approach to achieve this is appending a dummy part to the image src that changes when the image is updated, and what could be better than the file timestamp !!

So instead of

<img src="image.jpg" width="200">

use

<?php echo '<img src="image.jpg?m=' . filemtime('image.jpg') . '" width="200">'; ?>

Comments

Popular posts from this blog

Height in Feet and Cms using PHP

The following code can be used to generate a Select field as displayed in the image. It is done in core php. <select name="height" required> <option value="">Select</option> <?php for($inches=48;$inches<=78;$inches++) //Change the range in inches as required { $cm=ceil($inches*2.54); $feet=(($inches-($inches % 12))/12)."&rsquo; ".($inches % 12)."&rdquo;"; ?> <option value="<?php echo $cm; ?>"><?php echo $feet.' ('.$cm.' cms)'; ?></option> <?php } ?> </select> Keywords: html form select options convert height length inch cm cms to feet

WhatsApp for Windows stuck in Fullscreen

In case your whatsapp for windows is stuck in fullscreen, close Whatsapp and open the following file. C:\Users\ username \AppData\Roaming\WhatsApp\settings.json where username is your login ID in windows. The file can be opened with Notepad or any text editor. Change "isFullScreen":true to "isFullScreen":false Save the file and start WhatsApp. Now you can change the size of the window. (If required, you can change the size of whatsapp window from the json file too.

CRON Jobs

In Sentora Environment, CRON Jobs can be run using Root Level Crons or Sentora Crons. If it is a system level command like restarting services or backup outside the root, then system level cron should be used. For running php scripts like sending daily summary, mailing database backup, etc then Sentora cron should be used.