我使用这条路线:
GET | HEAD /资产/ @文件夹/ @型/ V- @版本/ * =控制器\资产 - >发送,3600
我控制器:
namespace controllers;
class Assets {
private $paths;
private $types = ['css', 'js', 'i', 'fonts', 'files', 'icons'];
private $dontminify = ['i', 'fonts', 'files', 'icons'];
public function __construct() {
$this->fw = \Base::instance();
$this->paths['app'] = '../app/views/site_tpl/assets/';
$this->paths['core'] = '../core/views/default/assets/';
}
public function send() {
if (in_array($this->fw->get('PARAMS.folder'), array_keys($this->paths))
&& in_array($this->fw->get('PARAMS.type'), $this->types))
{
$folder = $this->paths[$this->fw->get('PARAMS.folder')];
$type = $this->fw->get('PARAMS.type');
if (in_array($type, $this->dontminify)) {
$file = $folder . $type . '/' . $this->fw->pop('PARAMS');
if (\Web::instance()->send($file)) {
return true;
}
} else {
$this->fw->set('UI', $folder . $type . '/');
$file = $this->fw->pop('PARAMS');
if (file_exists($this->fw->get('UI') . $file)) {
if (!$this->fw->exists('GET.dontminify')) {
echo \Web::instance()->minify($file);
return true;
} elseif (\Web::instance()->send($this->fw->get('UI') . $file)) {
return true;
}
}
}
}
$this->fw->error(404);
}
}
所以,当我想更新文件的版本,我写somethong这样的:
<script src="/assets/app/js/v-20160205/main.js"></script>
哇!好吧...我会尝试! – Chris