Php 如果文件没有’;你没变吗?

Php 如果文件没有’;你没变吗?,php,zend-framework2,assetic,Php,Zend Framework2,Assetic,我使用的是Zend Framework 2,我的抽象控制器使用以下函数对模块中的所有资产进行分组,然后将它们写入/缩小到缓存文件,然后通过视图帮助器提供要写入页面的文件路径 protected function prepareAssets() { // Prepare FilterManager with all filters that will be used $FilterManager = new FilterManager(); $FilterManager-

我使用的是Zend Framework 2,我的抽象控制器使用以下函数对模块中的所有资产进行分组,然后将它们写入/缩小到缓存文件,然后通过视图帮助器提供要写入页面的文件路径

protected function prepareAssets() {

    // Prepare FilterManager with all filters that will be used
    $FilterManager = new FilterManager();
    $FilterManager->set('scss', new ScssphpFilter());
    $FilterManager->set('cssmin', new MinifyCssFilter());
    $FilterManager->set('jsmin', new JSMinFilter());

    $AssetManager = new AssetManager();
    // Prepare the AssetManager with all core assets
    $AssetManager->set('coreCss', new AssetCollection(array(
        new FileAsset('public/vendor/bootstrap/css/bootstrap.min.css'),
        new FileAsset('public/vendor/bootstrap/css/bootstrap-responsive.min.css'),
        new FileAsset('module/application/assets/css/fonts.css'),
        new FileAsset('module/application/assets/css/main.scss'),
    )));
    $AssetManager->set('coreJs', new AssetCollection(array(
        new FileAsset('public/vendor/modernizr/modernizr-2.6.2.js'),
        new FileAsset('public/vendor/respond/respond.min.js'),
        new FileAsset('public/vendor/jquery/jquery-1.9.1.min.js'),
        new FileAsset('public/vendor/bootstrap/js/bootstrap.min.js'),           
    )));

    // Add the controller specific assets
    $controllerCss = new AssetCollection();
    foreach ($this->assets['css'] as $file) {
        $controllerCss->add(new FileAsset($file));
    }
    $AssetManager->set('controllerCss', $controllerCss);
    $controllerJs = new AssetCollection();
    foreach ($this->assets['js'] as $file) {
        $controllerJs->add(new FileAsset($file));
    }
    $AssetManager->set('controllerJs', $controllerJs);

    // Setup factory to create the assets with cachebusting
    $factory = new AssetFactory('public/cache');
    $factory->setAssetManager($AssetManager);
    $factory->setFilterManager($FilterManager);
    //$factory->setDebug(true);
    $factory->addWorker(new CacheBustingWorker(CacheBustingWorker::STRATEGY_CONTENT));

    // Create the assets
    $coreCss = $factory->createAsset(array(
        '@coreCss',         
    ), array(
        'scss',
        '?cssmin',                  
    ));

    $controllerCss = $factory->createAsset(array(
        '@controllerCss',           
    ), array(
        'scss',
        '?cssmin',
    ));

    $coreJs = $factory->createAsset(array(
        '@coreJs',
    ), array(
        '?jsmin',
    ));

    $controllerJs = $factory->createAsset(array(
        '@controllerJs',            
    ), array(
        '?jsmin'
    ));

    // Write the assets to cache
    $writer = new AssetWriter('public/cache');
    $writer->writeAsset($coreCss);
    $writer->writeAsset($controllerCss);
    $writer->writeAsset($coreJs);
    $writer->writeAsset($controllerJs);

    // rename files with proper extensions to be served correctly
    $coreCssPath = $coreCss->getTargetPath(); rename(getcwd().'/public/cache/'.$coreCssPath, getcwd().'/public/cache/'.$coreCssPath.'.css');
    $controllerCssPath = $controllerCss->getTargetPath(); rename(getcwd().'/public/cache/'.$controllerCssPath, getcwd().'/public/cache/'.$controllerCssPath.'.css');
    $coreJsPath = $coreJs->getTargetPath(); rename(getcwd().'/public/cache/'.$coreJsPath, getcwd().'/public/cache/'.$coreJsPath.'.js');
    $controllerJsPath = $controllerJs->getTargetPath(); rename(getcwd().'/public/cache/'.$controllerJsPath, getcwd().'/public/cache/'.$controllerJsPath.'.js');

    // add paths to view model
    $view = $e->getParam('application')->getMvcEvent()->getViewModel();
    $view->coreCssPath = $coreCssPath.'.css';
    $view->controllerCssPath = $controllerCssPath.'.css';
    $view->coreJsPath = $coreJsPath.'.js';
    $view->controllerJsPath = $controllerJsPath.'.js';

}
但是,在运行时,无论原始文件是否已更改,每次页面加载都需要几秒钟,这告诉我它每次都通过过滤器处理文件,尽管缓存文件本身没有更新

我是否使用了CacheBastingWorker错误,或者我遗漏了其他东西