Skip to content

Instantly share code, notes, and snippets.

@Xvezda
Created April 10, 2018 11:24
Show Gist options
  • Save Xvezda/0e68f7209880819bcc3e0edf22df47be to your computer and use it in GitHub Desktop.
Save Xvezda/0e68f7209880819bcc3e0edf22df47be to your computer and use it in GitHub Desktop.
PHP static file query string ( by last modification time ) for browser cache revalidate
<?php
function load_script($file) {
echo '<script type="text/javascript" src="' . $file . "?t=" . filemtime($file) . '">
</script>' . PHP_EOL;
}
?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Javascript</title>
</head>
<body>
<?php load_script('./script.js'); ?>
</body>
</html>
'use strict';
// happy coding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment