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

Browser cache when using minification


i use asset manager to create collections of css and one collection for js files. When i use minification it works well, but i see that the minified files never gets loaded using the browser cache.

when i dont use minification it loads all the files leveragning browser cache. My question is how and if possible how to get browsers load the minified version of my collection fra internal browser cache.

Regards Sindre


I think you need to build a minified file and load that file. If the filename is constant, the browser will cache it. I don't believe the browser caches raw script tags with minified code in it if that's what you're trying to do.

The filename of the minified file is always the same: js.js

The same goes for css minification.

Here is the code:

            ->addFilter(new \Phalcon\Assets\Filters\Jsmin());

If I understand you want the new minified files are loaded instead of the old without minification is it? If so, try this.

//In your service.php
$di->setShared('view', function () use ($config) {

    $view = new View();


        '.volt' => function ($view, $di) use ($config) {

            $volt = new VoltEngine($view, $di);

                'compiledPath' => $config->application->cacheDir,
                'compiledSeparator' => '_',

                //ADD THIS LINE BELOW
                'compileAlways' => true

            return $volt;
        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'

    return $view;