We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Asset Manager

Hi, I'm using the following assets manager collection.

My question, is Assets manager will delete the file in the target path and create the new one for each request?

The issue I'm facing is, when I start load testing with jMeter on my app, some time I get broken page, while debugging I watch on assets dir

watch -n1 -d "ls -all /home/app/public/cache"

and noticed that the files size of my assets (commons.js, common.css, footer.js) is time to time equals to 0. So, it's looks like Assets Manager purge the assets files time to time? Or what I'm missing here?

private function initCommonJSCollection()
    {
        $this->assets
            ->collection('commonJs')
            ->setTargetPath('cache/common.js')
            ->setTargetUri('cache/common.js')
            ->addJs('js/jquery-1.11.1/jquery-1.11.1.min.js')
            ->addJs('js/panet/openx.js')
            ->addJs('js/panet/browser.js')
            ->addJs('js/panet/main.js')
            ->join(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin());

        $this->assets
            ->collection('commonCss')
            ->setTargetPath('cache/common.css')
            ->setTargetUri('cache/common.css')
            ->addCss('js/bootstrap-3.2.0/css/bootstrap.css')
            ->addCss('js/bootstrap-3.2.0/css/non-responsive.css')
            ->addCss('css/commons.css')
            ->addCss('css/extras.css')
            ->addCss('css/colors.css')
            ->addCss('css/vod.css')
            ->addCss('css/search.css');
//
        // In case of IE8 load the IE8 fonts
        if ($this->di->getBrowserInformer()->isIEOld()) $this->assets->collection('commonCss')->addCss('css/ie8-extras.css');

        $this->assets->collection('commonCss')
            ->join(true)
            ->addFilter(new \Phalcon\Assets\Filters\Cssmin());

        $this->assets
            ->collection('footerJS')
            ->setTargetPath('cache/footer.js')
            ->setTargetUri('cache/footer.js')
            ->addJs('js/bootstrap-3.2.0/js/bootstrap.min.js')
            ->addJs('js/shared.js')
            ->addJs('js/commons.js')
            ->addJs('js/webfontloader/webfontloader.js')
            ->addJs('js/extras.js')
            ->addJs('js/search.js')
            ->addJs('js/jquery-openx/jquery.openx.js')
            ->addJs('js/panet/openx-async.js')
            ->addJs('js/validate.js')
            ->join(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin());
    }


8.1k

Because you wrong in directory permissions set, may be. You can open your cache directory for user nginx.



19.1k

The cache dir have a 777 permissions.