N
N
newbie32016-07-31 13:04:21
Apache HTTP Server
newbie3, 2016-07-31 13:04:21

Setting up caching in Apache?

How to set up caching on the site?
what to enter in .htacess and whether it is necessary to enter something in HTML or not?
I couldn't find any good step by step instructions on google.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Azazel PW, 2016-08-01
@newbie3

<ifModule mod_expires.c>
ExpiresActive On
#по умолчанию кеш в 5 секунд
ExpiresDefault "access plus 1 days"
# Включаем кэширование изображений и флэш на месяц
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/jpeg "access plus 4 weeks"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 43829 minutes"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
 
# Включаем кэширование css, javascript и текстовых файлоф на одну неделю
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
 
# Включаем кэширование html и htm файлов на один день
ExpiresByType text/html "access plus 43200 seconds"
 
# Включаем кэширование xml файлов на десять минут
ExpiresByType application/xhtml+xml "access plus 600 seconds"
 
# Нестандартные шрифты сайта 
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</ifModule>
If you don't like errors from PageSpeed ​​Insights
Then you need to be more specific here.
For example, the Yandex and Google metrics must be downloaded and called on the server itself.
And make the crown auto-update, for example, once a day.
If the Yandex metric is not cached. it will be 99/100.
In general, about caching, I advise you to make your own cacher if the pages are static.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question