利用浏览器缓存并最小化重定向

时间:2019-03-27 17:12:23

标签: .htaccess caching optimization url-redirection browser-cache

我正在尝试提高网站的性能,但是以某种方式,当我阅读报告时,发现有些不太了解的东西。

我的网站是用WordPress构建的,但是非常干净,我没有安装很多插件,因为我大部分都是自己构建的。

所以我的问题是:

利用浏览器缓存-报告:

https://js.hs-scripts.com/3833369.js (1 minute)
https://js.hs-analytics.net/analytics/1553706000000/3833369.js (5 minutes)
https://js.hsadspixel.net/fb.js (10 minutes)
https://js.usemessages.com/conversations-embed.js (10 minutes)
https://www.googletagmanager.com/gtag/js?id=AW-1031048769 (15 minutes)
https://www.googletagmanager.com/gtm.js?id=GTM-TBCGVL (15 minutes)
https://connect.facebook.net/en_US/fbevents.js (20 minutes)
https://connect.facebook.net/signals/config/719765148155095?v=2.8.45&r=stable (20 minutes)
https://www.googleadservices.com/pagead/conversion_async.js (1 hour)
https://www.google-analytics.com/analytics.js (2 hours)

我为所有脚本和CSS设置了所有标头,因此这部分代码不应出现在本节中。

最小化重定向->报告

https://px.ads.linkedin.com/collect/?time=1553706091452&pid=810212&url=https%3A%2F%2Fwww.stenbergcollege.com%2F&fmt=js&s=1
https://px.ads.linkedin.com/collect/?time=1553706091452&pid=810212&url=https%3A%2F%2Fwww.stenbergcollege.com%2F&fmt=js&s=1&cookiesTest=true
https://www.linkedin.com/px/li_sync?redirect=https%3A%2F%2Fpx.ads.linkedin.com%2Fcollect%2F%3Ftime%3D1553706091452%26pid%3D810212%26url%3Dhttps%253A%252F%252Fwww.stenbergcollege.com%252F%26fmt%3Djs%26s%3D1%26cookiesTest%3Dtrue%26liSync%3Dtrue
https://px.ads.linkedin.com/collect/?time=1553706091452&pid=810212&url=https%3A%2F%2Fwww.stenbergcollege.com%2F&fmt=js&s=1&cookiesTest=true&liSync=true

我不知道这些链接是从哪里来的。

我的.htaccess文件如下所示:

<IfModule mod_rewrite.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
RewriteEngine On

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

是否有我忘记添加的内容?有很多插件可以为您完成工作,但是我想了解我的错误在哪里。

1 个答案:

答案 0 :(得分:1)

如果您想继续使用Google Tag,Facebook Tag和LinkedIn转换像素跟踪数据,我认为您将无能为力。我在这里也面临着同样的情况。