Return to Snippet

Revision: 77506
at September 27, 2019 12:02 by daemondevin


Initial Code
<?php
/**
 * lastModified
 *
 * @author     demon.devin
 * @link       PortableAppz.cu.cc/
 * @copyright  2016
 * @package    lastMofified
 * @version    1.0
 *
 * 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.
 *
 * PARAMETERS
 * $filepath  string   path to the file of the document you wish to use
 *
 * EXAMPLE:
 * <link rel="stylesheet" type="text/css" href="<?php echo lastModified('../css/style.css'); ?>" />
 *
 * OUTPUT:
 * <link rel="stylesheet" type="text/css" href="style.css?1477050530" />
 */

//
//default settings
if (!function_exists(lastModified)){
    function lastModified($filepath) {
        $lastModified = filemtime($path.$file);
        $timeStamp = $filepath.'?'.$lastModified;

        return $timeStamp;
    }
}

?>

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

Initial Description
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.

Initial Title
lastModified.func.php

Initial Tags
javascript, cache

Initial Language
PHP