After clearing the cache, is there any way to create a view cache files before user visits the page? Currently we are using the below command which creates a few of the cache files but not the view ones.
symfony cache:prime --env=qa frontend
After clearing the cache, is there any way to create a view cache files before user visits the page? Currently we are using the below command which creates a few of the cache files but not the view ones.
symfony cache:prime --env=qa frontend
Yes there is a way to generate cache files before a user visits the page. You need to create a cache warm-up script. A simple curl command to each URL will create the cache files:
curl http://myapp.example.com/user/action/
Another option is to create a PHP script, and using Symfony's built-in browser that is normally used for testing, you can use it for warming up your cache, like this example:
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'staging', false);
sfContext::createInstance($configuration);
// Array of URLs to browse
$pages = array(
'/foo/index',
'/foo/bar/id/1',
...
);
$b = new sfBrowser();
foreach ($pages as $page)
{
$b->get($page);
}
There is more information here http://symfony.com/legacy/doc/gentle-introduction/1_4/en/18-Performance under the Generating Cached Pages section and more information about caching is here http://symfony.com/legacy/doc/gentle-introduction/1_4/en/12-Caching