perf: V0.9.4 商品列表分页 + sitemap 文件缓存 + banner/asset/gzip/类型修复
- P1: Product::listing() 分页(WHERE status=1+LIMIT/OFFSET+总数),ProductController 改用并加翻页器,消除列表全表
- P1: outputSitemap() 加 storage/cache/sitemap.xml 文件缓存(TTL 3600s),消除每次爬虫全表
- P2: 首页 banner 改 whereLimit('status',1,20)
- P2: asset() 追加 ?v=filemtime 版本串,theme.css 改后自动击穿 1y 浏览器缓存
- P2: nginx 启用 gzip(文本资源压缩)
- P2: Model::count() $val 隐式可空改 mixed(PHP 8.4+ 弃用)
This commit is contained in:
+8
-1
@@ -24,7 +24,14 @@ if (!function_exists('site_url')) {
|
||||
}
|
||||
function asset(string $path = ''): string
|
||||
{
|
||||
return site_url('assets/' . ltrim($path, '/'));
|
||||
$url = site_url('assets/' . ltrim($path, '/'));
|
||||
// V0.9.4:追加文件 mtime 作为版本串,使 theme.css 等静态资源在「重新生成/部署」后自动击穿浏览器长缓存
|
||||
//(nginx 对已改资源设了 expires 1y,无版本串会导致老访客最长 1 年看不到更新)。
|
||||
$real = rtrim(BASE_PATH, '/') . '/public/assets/' . ltrim($path, '/');
|
||||
if (is_file($real)) {
|
||||
$url .= '?v=' . filemtime($real);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
function e($v): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user