Skip to content

Instantly share code, notes, and snippets.

@delphinpro
Created March 22, 2018 01:27
Show Gist options
  • Save delphinpro/4120dc161a78ddd307a6566c07048e6b to your computer and use it in GitHub Desktop.
Save delphinpro/4120dc161a78ddd307a6566c07048e6b to your computer and use it in GitHub Desktop.
<?php
$file = isset($file) ? $file : '';
$cacheable = isset($cacheable) ? intval($cacheable) : 0; // 1 or 0
if (empty($file)) {
return;
}
$filePath = MODX_BASE_PATH . $file;
if (!file_exists($filePath) || !is_readable($filePath)) {
return;
}
$md5File = '';
if ($cacheable === 0) {
$md5File = '?nocache='.md5_file($filePath);
}
return $file.$md5File;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment