1

我正在尝试优化我的网站的渲染速度。

但是 Nginx 没有使用 rel="preload" 提供 css 链接,当它是 rel="stylesheet" 时它工作正常。

<link href="css/fontawesome.css" rel="preload" onload="clearRel()" as="style"/>

我安装了一个新的 nginx 版本 1.13.7,这是我安装的模块:

nginx version: nginx/1.13.7
built by gcc 4.9.2 (Debian 4.9.2-10) 
built with OpenSSL 1.0.2l  25 May 2017
TLS SNI support enabled
configure arguments: --add-module=/root/ngx_pagespeed-latest-stable
--with-compat
--with-file-aio
--with-threads
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_slice_module
--with-http_ssl_module
--with-http_sub_module
--with-http_stub_status_module
--with-http_v2_module
--with-http_secure_link_module
--with-mail
--with-mail_ssl_module
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-debug
--with-cc-opt='-g
-O2
-fPIE
-fstack-protector-strong
-Wformat
-Werror=format-security
-Wdate-time
-D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-Bsymbolic-functions
-fPIE
-pie
-Wl,-z,relro
-Wl,-z,now'

当它在 rel="preload" 上时,我没有匹配的 css 文件日志。

你能帮我吗?

非常感谢您提前。

4

1 回答 1

0

我解决了这个问题。阻止预加载链接的是 Google PageSpeed 模块。我添加了一个 Nginx 指令,一切顺利:

pagespeed EnableFilters inline_css;

感谢您的时间。

于 2017-12-26T19:56:51.243 回答