Wed. Jun 3rd, 2020

Optimasi Plugin WP Super Cache di Nginx Web Server

Hello mas brot, lagi2 artikel ini hanyalah kopas mentah2 belaka karena memang ogut sangat tidak pandai bikin artikel, apalagi tutorial xexexexexex….

Bagi yang ga ngerti apa itu web server, nginx, ssh lan konco2ne mending ga usah baca artikel ini, dari pada nanti malah pusing, klemun2, terus mutah :v

Okelah kalo begitu, karena 2 paragraph di atas saya sudah yakin sangat unik sekali karena memang hasil pemikiran sendiri, jadi mari kita masuk ke Kopas 😀

Standard WordPress-Nginx configuration with WP Super cache support:

As you are getting into Nginx, I hope you don’t need my help with configuring WP Super Cache plugin.

Still, make sure you are using “Use mod_rewrite to serve cache files. (Recommended)” option under “Advanced” tab.

Following configuration supports:

  1. Static Page Caching using Disk
  2. Direct browser cache for static content like images, js, css, etc
server {

	access_log   /var/log/nginx/;
	error_log    /var/log/nginx/ debug;

	root /var/www/;
	index index.php;

	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; }

	location ~ \.php$ {
		try_files $uri =404; 
		include fastcgi_params;

	# 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;



To simplify configuration, I haven’t added Mobile user agent checks. We are in the iPhone era where finally phones are getting smart. So there is no need to create separate mobile site, when you can cater to today’s iPhone/Android devices using responsive designs.

Don’t Forget:

Always test your Nginx configuration and then reload it. All changes to Nginx config must be followed with these commands:

nginx -t && service nginx reload

Important Note:

WP Super Cache caching will conflict with plugins that uses query vars. WooCommerce is an example known plugin known to work with above configuration. Reason is following line: 

try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;

It doesn’t passes $args to /index.php. If you set last try_files argument to /index.php?$args as with other WordPress-Nginx configuration, WP Super Cache, itself will break!

if you get error like this “Mod rewrite may not be installed” just install this plugin the remove the error

Artikel ini sepenuhnya diKopas dari –>

You may have missed