Posted By


daemondevin on 09/27/19

Tagged


Statistics


Viewed 10771 times
Favorited by 0 user(s)

lastModified.func.php


/ Published in: PHP
Save to your folder(s)

With this snippet you will have the ability to deliver the most recent version of any file.

When dealing with a browser's cache you can't be certain your viewers are getting the most recent copy. By appending a GET value (the UNIX timestamp) to, for example, a stylesheet, you can make the browser think the stylesheet is dynamic, thus reloading the stylesheet time the modification date changes.


Copy this code and paste it in your HTML
  1. <?php
  2. /**
  3.  * lastModified
  4.  *
  5.  * @author demon.devin
  6.  * @link PortableAppz.cu.cc/
  7.  * @copyright 2016
  8.  * @package lastMofified
  9.  * @version 1.0
  10.  *
  11.  * With this snippet you will have the ability to deliver the most recent version of any file.
  12.  * When dealing with a browser's cache you can't be certain your viewers are getting the most
  13.  * recent copy. By appending a GET value (the UNIX timestamp) to, for example, a stylesheet,
  14.  * you can make the browser think the stylesheet is dynamic, thus reloading the stylesheet time
  15.  * the modification date changes.
  16.  *
  17.  * PARAMETERS
  18.  * $filepath string path to the file of the document you wish to use
  19.  *
  20.  * EXAMPLE:
  21.  * <link rel="stylesheet" type="text/css" href="<?php echo lastModified('../css/style.css'); ?>" />
  22.  *
  23.  * OUTPUT:
  24.  * <link rel="stylesheet" type="text/css" href="style.css?1477050530" />
  25.  */
  26.  
  27. //
  28. //default settings
  29. if (!function_exists(lastModified)){
  30. function lastModified($filepath) {
  31. $lastModified = filemtime($path.$file);
  32. $timeStamp = $filepath.'?'.$lastModified;
  33.  
  34. return $timeStamp;
  35. }
  36. }
  37.  
  38. ?>

URL: http://portableappz.x10.mx/extras/lastModified

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.