Cara Konfigurasi WP Super Cache di Nginx

WP Super Cache merupakan plugin yang digunakan untuk menggandakan halaman atau membuat sebuah cache dari website kita dan menyimpannya di dalam server yang kita gunakan. Sehingga ketika kita ingin membuka halaman yang ada di website, respon dari server akan lebih cepat, karena server sudah menyimpan salinannya.

Tutorial ini untuk pengguna VPS yang menggunakan web server Nginx.

Untuk mengkonfigurasikan plugin WP Super Cache di web server Nginx sebelumnya sudah ter-install PHP, MySQL, Nginx dan wordpress.

Di tutorial ini penulis tidak mengajarkan konfigurasi plugin WP Super Cache (penulis anggap kamu sudah paham untuk pengaturan WP Super Cache di menu admin WordPress kamu).

Namun, pastikan kamu menggunakan  “Use mod_rewrite to serve cache files. pilihan di bawah tab “Advanced “.

Berikut konfigurasinya untuk nginx file example.conf

  • Halaman Caching statis menggunakan Disk
  • Cache browser langsung untuk konten statis seperti gambar, js, css, dll
server {
listen 80;
#listen [::]:80 ipv6only=on default_server;
server_name inwepo.co www.inwepo.co ;
root /srv/www/inwepo.co/htdocs;
access_log /srv/www/inwepo.co/logs/access.log;
error_log /srv/www/inwepo.co/logs/error.log;
if ($http_host != "inwepo.co") {
rewrite ^ http://inwepo.co$request_uri permanent;
}
index index.php index.htm index.html;

set $cache_uri $request_uri;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}

# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
}

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }

# Pass PHP scripts on to PHP-FPM
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri /index.php;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}

# Cache static files for as long as possible
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires max; log_not_found off; access_log off;
}

Dengan menggunakan kode diatas kamu dapat mengaktifkan WP Super Cache untuk pengguna WordPress di Nginx

Komentar

Leave a Reply

Your email address will not be published. Required fields are marked *

Trending Minggu Ini

Inwepo adalah media platform yang membantu setiap orang untuk belajar dan berbagi tutorial, tips dan trik cara penyelesaian suatu masalah di kehidupan sehari-hari dalam bentuk teks, gambar. dan video.

Dengan bergabung bersama kami dan membuat 1 tutorial terbaik yang kamu miliki dapat membantu jutaan orang di Indonesia untuk mendapatkan solusinya. Ayo berbagi tutorial terbaikmu.

Ikuti Kami di Sosmed

Inwepo Navigasi

Tentang Kami             Beranda

Hubungi Kami             Panduan Penulis

Kebijakan Privasi

FAQ

Partner

Copyright © 2014 - 2023 Inwepo - All Rights Reserved.

To Top