Reputation: 13886
I trying to make my prestashop site faster. My question is: is there a way to get all products pages cached AT ONCE. I already enabled the cache. But if you visit a page for the first time it take too much time to load. Then, the second visit is much faster.
I don't see any feature in the admin page to get this.
Thanks.
Upvotes: 1
Views: 188
Reputation: 5748
There is no but you can create a script which will load every product pages on your website.
Put this script at the root of your Prestashop installation /test.php
. and call it from your browser www.mywebsite.com/test.php
:
<?php
// The script will not timeout for 10 hours
set_time_limit(36000);
// Set the right path to config.inc.php
include_once (__DIR__ . '/config/config.inc.php');
// Set a default controller to remove unwanted warnings.
$context = Context::getContext();
$context->controller = new FrontController();
// Get all products
$products = Product::getProducts(1, 0, 1000000, 'id_product', 'DESC', false, true, $context);
foreach ($products as $product)
{
// Load the product page
$link = $context->link->getProductLink($product['id_product']);
file_get_contents($link);
// Print this to screen right away
print "loaded: " . $link . "<br />";
ob_flush();
flush();
// Stop for 0.2 seconds
usleep(200000);
}
Upvotes: 1