如何在moodle中利用浏览器缓存

时间:2017-01-28 07:00:25

标签: php .htaccess moodle pagespeed

我在根目录中的.htaccess文件中添加了以下代码,但它没有做任何事情。如何正确利用缓存?

UNNotificationAttachment

1 个答案:

答案 0 :(得分:0)

您的代码没有任何问题,但它不够广泛。尝试使用下面的代码,这涵盖了Leverage Browser Caching的各个方面。除了外部文件:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On

## IMAGES ##
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 image/x-icon "access plus 1 year"

## CSS ##
ExpiresByType text/css "access plus 1 month"

## HTML ##
ExpiresByType text/html "access plus 1 month"

## JAVASCRIPT ##
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/json "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresDefault "access plus 1 month"
</ifModule>

如果您还想缓存外部文件,请参阅答案:Leverage Browser Caching for 3rd Party JS.

相关问题