Gtmetrix:在我的 .htaccess、Apache 服务器上添加过期 headers,这是显示问题的结果和我的 .htaccess 文件配置

Gtmetrix : Add Expires headers on my .htaccess, Apache Server ,, here are the results showing the issue and my .htaccess file configuration

在处理我的 css 文件(将它们合并到一个文件中...)和 img alt、优化图像大小并启用 gzip 之后,我正在优化托管在 Apache Web 服务器上的我的网站对于浏览器,...我总是得到低于 58% 的 YSlow 分数和等于 80% 的 PageSpeed,请需要帮助!

the image is showing the components that said that they don't have a "far-future expiration date" (click here)

这是我的 .htaccess 文件,我在其中放置了一些配置,这些配置是我在 Gtmetrix.com

上找到的解决方案
<IfModule mod_rewrite.c>
############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on
#    RewriteCond %{HTTP_HOST}!^www\.exemple\.com

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
#    RewriteRule .* - [S=1]
    RewriteRule .* index.php [L]
#    RewriteRule (.*)http://www.exemple.com/ [R=301,L]

</IfModule>


#******************Non www redirect – Canonical Issue******************





#************"Compressing files / caching"
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
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 mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>



<IfModule mod_headers.c>
    <FilesMatch "\.(bmp|css|flv|gif|ico|jpg|jpeg|js|pdf|png|svg|swf|tif|tiff|woff|eot|ttif)(\.gz)?$">

        Header set Expires "Thu, 22 Mar 2018 20:00:00 GMT"
        Header unset Etag
        FileETag None

        Header set cache-control "max-age=2592000, public"
    </FilesMatch>
</IfModule>

我看到了你从 Gtmetrix 得到的屏幕截图,我认为你的一切都很好,而且那些文件是外部文件,所以你不能优化它们:) !检查其他建议并尝试修复它们以获得良好的 YSlow 分数,最好的问候兄弟 :)