Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 使用高效缓存策略服务静态资产-Google PageSpeed Insights_.htaccess_Amazon S3_Octobercms_Pagespeed Insights - Fatal编程技术网

.htaccess 使用高效缓存策略服务静态资产-Google PageSpeed Insights

.htaccess 使用高效缓存策略服务静态资产-Google PageSpeed Insights,.htaccess,amazon-s3,octobercms,pagespeed-insights,.htaccess,Amazon S3,Octobercms,Pagespeed Insights,我使用的是apache服务器,我使用的是AWS,当我进行PageSpeed测试时,我不断收到这样的错误信息 使用高效的缓存策略为静态资产提供服务 这是我的.htaccess文件代码,用于对抗此错误 .htaccess <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> <IfModule mo

我使用的是apache服务器,我使用的是AWS,当我进行PageSpeed测试时,我不断收到这样的错误信息

使用高效的缓存策略为静态资产提供服务

这是我的.htaccess文件代码,用于对抗此错误

.htaccess

<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    <IfModule mod_headers.c>
        <If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">            
            Header always set Strict-Transport-Security "max-age=31536000"
        </If>
    </IfModule>

 

    ### MY OTHER DEFAULT CODE OF OCTOBERCMS WHICH IS NOT RELATED TO COMPRESSION ETC ... 

</IfModule>


# TN START GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# TN END GZIP COMPRESSION

# TN START DEFLATE COMPRESSION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
# END DEFLATE COMPRESSION

# TN START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive

# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>

# WEEK
<FilesMatch "\.(js|css|swf)$">
    Header set Cache-Control "max-age=604800"
</FilesMatch>

</ifModule>
# TN END ENABLE KEEP ALIVE

# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access plus 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/webp "access plus 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/svg "access 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/xhtml-xml "access 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"

# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"

ExpiresDefault "access 1 month"
</IfModule>
# TN - END EXPIRES CACHING #

选项-多视图
标头始终设置严格的传输安全性“最大年龄=31536000”
###我的另一个默认代码OCTOBERCMS与压缩等无关。。。
#TN启动GZIP压缩
mod_gzip_on Yes
是的
mod_gzip_item_include file\(html?| txt | css | js | php | pl)$
mod_gzip_item_包含处理程序^cgi脚本$
mod_gzip_项目包括mime^text/*
mod_gzip_item_包括mime^application/x-javascript*
mod_gzip_项_排除mime^image/*
mod_gzip_item_排除rspheader^内容编码:.*gzip*
#TN-END-GZIP压缩
#TN开始放气压缩
AddOutputFilterByType DEFLATE“应用程序/atom+xml”\
“应用程序/javascript”\
“应用程序/json”\
“应用程序/ld+json”\
“应用程序/清单+json”\
“应用程序/rdf+xml”\
“应用程序/rss+xml”\
“应用程序/架构+json”\
“应用程序/vnd.geo+json”\
“应用程序/vnd.ms fontobject”\
“应用程序/x-font”\
“应用程序/x-font-opentype”\
“应用程序/x-font-otf”\
“应用程序/x-font-truetype”\
“应用程序/x-font-ttf”\
“应用程序/x-javascript”\
“应用程序/x-web-app-manifest+json”\
“应用程序/xhtml+xml”\
“应用程序/xml”\
“字体/eot”\
“字体/otf”\
“字体/ttf”\
“字体/opentype”\
“图像/bmp”\
“图像/svg+xml”\
“image/vnd.microsoft.icon”\
“图像/x图标”\
“文本/缓存清单”\
“文本/css”\
“文本/html”\
“文本/javascript”\
“文本/纯文本”\
“文本/vcard”\
“text/vnd.rim.location.xloc”\
“文本/vtt”\
“文本/x组件”\
“文本/x-跨域-策略”\
“文本/xml”
#末端放气压缩
#TN启动启用保持活动状态
标题集连接保持活动状态
#周
标题集缓存控制“最大年龄=604800,公共”
#周
标题集缓存控制“最大年龄=604800”
#TN END使能保持活动状态
#TN-启动缓存过期#
过期于
ExpiresByType文本/css“访问1个月”
ExpiresByType文本/javascript“访问加1个月”
ExpiresByType text/html“访问1个月”
ExpiresByType image/gif“访问1年”
过期按类型图像/png“访问1年”
过期按类型映像/jpg“访问1年”
过期按类型图像/jpeg“访问1年”
过期按类型映像/webp“访问加1年”
过期按类型图像/x图标“访问1年”
ExpiresByType图像/svg+xml“访问加1个月”
ExpiresByType图像/svg“访问1年”
按类型音频/ogg“访问加1年”过期
按类型视频/mp4“访问加1年”过期
过期按类型视频/mpeg“访问加1年”
按类型视频/ogg“访问加1年”过期
按类型视频/webm“访问加1年”过期
ExpiresByType应用程序/atom+xml“访问加1小时”
ExpiresByType应用程序/rss+xml“访问加1小时”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType应用程序/javascript“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
ExpiresByType应用程序/xhtml xml“访问1个月”
ExpiresByType文本/x组件“访问加1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
ExpiresByType字体/opentype“访问加1个月”
ExpiresByType应用程序/vnd.ms-fontobject“访问加1个月”
按类型应用程序到期/x-font-ttf“访问加1个月”
过期按类型应用程序/font woff“访问加1个月”
ExpiresByType应用程序/font-woff2“访问加1个月”
ExpiresByType image/vnd.microsoft.icon“访问加1年”
#字体
ExpiresByType字体/ttf“访问加1年”
ExpiresByType字体/otf“访问加1年”
ExpiresByType字体/woff“访问加1年”
ExpiresByType字体/woff2“访问加1年”
过期按类型应用程序/font woff“访问加1年”
ExpiresDefault“访问1个月”
#TN-结束缓存过期#
但仍然需要77个资源来保持这个错误

正如您所看到的,我已经尝试了很多东西,添加了这么多代码,但错误计数并没有减少,它也不断得到.js、.png、.css文件

有人能告诉我代码中缺少了什么吗

谢谢


更新的HTACCESS文件

<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    <IfModule mod_headers.c>
        <If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">            
            Header always set Strict-Transport-Security "max-age=31536000"
        </If>
    </IfModule>

    RewriteEngine On

    ##
    ## You may need to uncomment the following line for some hosting environments,
    ## if you have installed to a subdirectory, enter the name here also.
    ##
    # RewriteBase /   


</IfModule>


# TN START GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# TN END GZIP COMPRESSION

# TN START DEFLATE COMPRESSION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
# END DEFLATE COMPRESSION

# TN START ENABLE KEEP ALIVE
<IfModule mod_headers.c>
    Header set Connection keep-alive

</IfModule>
# TN END ENABLE KEEP ALIVE

# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On

ExpiresDefault "access plus 1 month"

ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/svg "access plus 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/xhtml-xml "access plus 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"

# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"

  <IfModule mod_headers.c>
          Header append Cache-Control "public"
  </IfModule>


</IfModule>


<IfModule mod_headers.c>
  Header unset ETag
</IfModule>
FileETag None

<IfModule mod_headers.c>
  Header unset Last-Modified
</IfModule>

# TN - END EXPIRES CACHING #

选项-多视图
标头始终设置严格的传输安全性“最大年龄=31536000”
重新启动发动机
##
##对于某些托管环境,您可能需要取消注释以下行,
##如果已安装到子目录,请在此处输入名称。
##
#重写基/
#TN启动GZIP压缩
mod_gzip_on Yes
是的
mod_gzip_item_include file\(html?| txt | css | js | php | pl)$
mod_gzip_item_包含处理程序^cgi脚本$
mod_gzip_项目包括mime^text/*
mod_gzip_item_包括mime^application/x-javascript*
mod_gzip_项_排除mime^image/*
mod_gzip_item_排除rspheader^内容编码:.*gzip*
#TN-END-GZIP压缩
#TN开始放气压缩
AddOutputFilterByType DEFLATE“应用程序/atom+xml”\
“应用程序/javascript”\
“应用程序/json”\
“应用程序/ld+json”\
“应用程序/清单+json”\
“应用程序/rdf+xml”\
“应用程序/rss+xml”\
“应用程序/架构+json”\
“应用程序/vnd.geo+json”\
“应用程序/vnd.ms fontobject”\
“应用程序/x-font”\
“应用程序/x-font-opentype”\
“应用程序/x-font-otf”\
“应用程序/x-font-truetype”\
“应用程序/x-font-ttf”\
“应用程序/x-javascript”\
“应用程序/x-web-app-manifest+json”\
“应用程序/xhtml+xml”\
“应用程序/xml”\
“字体/eot”\
“字体/otf”\
“字体/ttf”\
“字体/opentype”\
“图像/bmp”\
“图像/svg+xml”\
“image/vnd.microsoft.icon”\
“图像/x图标”\
“文本/缓存清单”\
“文本/css”\
“文本/html”\
“文本/javascript”\
“文本/纯文本”\
“文本/vcard”\
“text/vnd.rim.location.xloc”\
“文本/vtt”\
“文本/x组件”\
“文本/x-跨域-策略”\
“文本
cache-control: max-age=2592000, public
expires: Thu, 12 May 2022 16:05:33 GMT
ExpiresByType image/jpeg "access 1 year"
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>
...config/176…?v=2.9.39&r=stable(connect.facebook.net)        20m
...industries/nonprofit.svg(www.rosterelf.com)                30 d

ExpiresByType image/svg+xml "access plus 1 month"
...js/swiper-bundle.min.js(www.rosterelf.com)                 30 d

ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
...css/custom.min.css(www.rosterelf.com)                     30 d

ExpiresByType text/css "access plus 1 month"
... fonts/social-media-icon.ttf?lvmhu5(www.rosterelf.com)    30 d
ExpiresByType application/font-sfnt "access plus 1 year"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"

# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"