Neste tutorial, você aprenderá como otimizar seu WordPress para que suas páginas carreguem rapidamente.
Edite o arquivo .htaccess do seu WordPress em um editor de texto e adicione as seguintes linhas no início do arquivo:
# BEGIN SafePress
RewriteEngine On
# Disable custom 404 error page for PHP and static content
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(/[^/]+)?/wp-(content|admin|includes)/ [OR]
RewriteCond %{REQUEST_FILENAME} ^.+\.(php|html|txt|xml|js|css|jpeg|jpg|png|ico|webp|avif)$ [NC]
RewriteRule ^ - [R=404,L]
# Protect WordPress from automated attacks
RewriteCond %{HTTP_USER_AGENT} ^(python\-|Go\-http\-client)
RewriteRule ^ - [R=404,L]
# Security headers
Header set Strict-Transport-Security "max-age=31536000"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-Content-Type-Options "nosniff"
Header set Upgrade-Insecure-Requests "1"
Header set Referrer-Policy "same-origin"
Header set Permissions-Policy "sync-xhr=(self)"
Header set Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval' https: data: blob:;"
Header set X-XSS-Protection "1; mode=block"
# Cache headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-font-opentype "access plus 1 month"
ExpiresByType application/x-font-truetype "access plus 1 month"
ExpiresByType application/x-icon "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/avif "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
</IfModule>
# END SafePress
Acesse a administração do seu WordPress e instale o plugin WP Fastest Cache.
Ative o plugin e configure os parâmetros conforme imagem abaixo:
Acesse www.gtmetrix.com e faça um teste no seu site.
Siga as sugestões de otimização, em especial nas imagens do site, para obter uma melhor nota de performance.