有没有办法为 Prestashop 中的所有页面准备缓存?
Is there a way to prime the cache for all pages in Prestashop?
我想让我的 prestashop 网站更快。我的问题是:有没有办法让所有的产品页面都缓存一次。我已经启用了缓存。但是,如果您是第一次访问某个页面,则需要花费太多时间来加载。那么,第二次访问就快多了。
我在管理页面中没有看到任何功能可以获取此信息。
谢谢。
没有,但您可以创建一个脚本来加载您网站上的每个产品页面。
将此脚本放在 Prestashop 安装的根目录下 /test.php
。并从您的浏览器中调用它 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);
}
我想让我的 prestashop 网站更快。我的问题是:有没有办法让所有的产品页面都缓存一次。我已经启用了缓存。但是,如果您是第一次访问某个页面,则需要花费太多时间来加载。那么,第二次访问就快多了。
我在管理页面中没有看到任何功能可以获取此信息。
谢谢。
没有,但您可以创建一个脚本来加载您网站上的每个产品页面。
将此脚本放在 Prestashop 安装的根目录下 /test.php
。并从您的浏览器中调用它 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);
}