gpt4 book ai didi

apache - 在 ubuntu 14.04 上的 Apache2 中设置缓存

转载 作者:行者123 更新时间:2023-12-04 19:17:12 25 4
gpt4 key购买 nike

我正在尝试在我的服务器上设置缓存,这是我的 htaccess。该代码来自不同的网站(缓存代码)。我真的找不到最新版本的 apache mod_expires.c 是否仍在使用,并且我还使用了命令 sudo a2enmod expires ,该命令有效,然后我重新启动了 Web 服务器。我正在使用页面洞察力来检查杠杆/缓存是否有效,但似乎不起作用,甚至重新加载网站我可以看到图像已下载且未立即加载。

ErrorDocument 404 /
ErrorDocument 403 /

Options ALL -Indexes

RewriteEngine On

RewriteEngine On


RewriteRule ^([0-9]+\.[^a-zA-Z]+)$ index.php?Patch_No=$1 [NC,L]

RewriteRule ^([0-9]+\.[^a-zA-Z]+)&([0-9a-zA-Z_-]+)$ index.php?Patch_No=$1&tab=$2 [NC,L]

RewriteRule ^patches php/patches.php [NC,L]

RewriteRule ^([^0-9][\s'0-9a-zA-Z_-]+[^0-9])$ index.php?Champion=$1 [NC,L]

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

最佳答案

sudo a2enmod file_cache



sudo service apache2 restart

打开
 sudo nano /etc/apache2/apache2.conf

在 .htaccess 下添加以下行
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

然后
sudo service apache2 restart

关于apache - 在 ubuntu 14.04 上的 Apache2 中设置缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33421267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com