我已通过以下设置实施了resourec到期
<IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/pdf "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType image/x-icon "access plus 1 year" ExpiresDefault "access plus 2 days" </IfModule>
与a2dismod到期,正如预期的那样我没有Expires标题:
wget --server-response --no-check-certificate https://sandBox.trinityp3.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 --2018-10-17 07:57:09-- https://sandBox.trinityp3.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 Resolving sandBox.trinityp3.com (sandBox.trinityp3.com)... 52.77.97.226 Connecting to sandBox.trinityp3.com (sandBox.trinityp3.com)|52.77.97.226|:443... connected. WARNING: cannot verify sandBox.trinityp3.com's certificate,issued by ‘emailAddress=mark@xxx.xxx,CN=sandBox.trinityp3.com,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU’: Self-signed certificate encountered. HTTP request sent,awaiting response... HTTP/1.1 200 OK Date: Tue,16 Oct 2018 18:57:10 GMT Server: Apache/2.4.10 (Ubuntu) Last-Modified: Tue,06 Sep 2016 02:32:13 GMT Accept-Ranges: bytes Content-Length: 97184 Vary: Accept-Encoding Access-Control-Allow-Origin: * Referrer-Policy: Cache-Control: max-age=604800,public Keep-Alive: timeout=5,max=100 Connection: Keep-Alive Content-Type: application/x-javascript
随着a2enmod到期,我得到1年的到期回复
wget --server-response --no-check-certificate https://sandBox.trinityp3.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 --2018-10-17 08:01:26-- https://sandBox.trinityp3.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 Resolving sandBox.trinityp3.com (sandBox.trinityp3.com)... 52.77.97.226 Connecting to sandBox.trinityp3.com (sandBox.trinityp3.com)|52.77.97.226|:443... connected. WARNING: cannot verify sandBox.trinityp3.com's certificate,16 Oct 2018 19:01:27 GMT Server: Apache/2.4.10 (Ubuntu) Last-Modified: Tue,06 Sep 2016 02:32:13 GMT Accept-Ranges: bytes Content-Length: 97184 Vary: Accept-Encoding Cache-Control: max-age=604800,public Expires: Wed,16 Oct 2019 19:01:27 GMT Access-Control-Allow-Origin: * Referrer-Policy: Keep-Alive: timeout=5,max=100 Connection: Keep-Alive Content-Type: application/x-javascript
我也运行grep来查找任何其他expires语句,但没有.
添加ExpiresByType application / x-javascript后,问题仍然存在.与deflate有冲突吗?
ubuntu@sandBox:/etc/apache2$grep -r application/x-javascript * mods-available/deflate.conf: AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript sites-available/710-tp3-au-www-sandBox.conf: ExpiresByType application/x-javascript "access plus 1 month" sites-available/710-tp3-au-www-sandBox.conf: ExpiresByType application/x-javascript "access plus 1 month"
您没有针对application / x-javascript Content-Type的ExpiresByType规则.您的.js文件正在作为服务.