-
-
Save Hadryan/6f16667877b4e1f2b93ff7eb8fd1ace7 to your computer and use it in GitHub Desktop.
Micro caching for Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TODO: Compare with: https://www.howtoforge.com/why-you-should-always-use-nginx-with-microcaching | |
mkdir /usr/share/nginx/cache | |
#mkdir /var/run/nginx/cache | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_cache microcache; | |
fastcgi_cache_key $scheme$host$request_uri$request_method; | |
fastcgi_cache_valid 200 301 302 30s; | |
fastcgi_cache_use_stale updating error timeout invalid_header http_500; | |
fastcgi_pass_header Set-Cookie; | |
fastcgi_pass_header Cookie; | |
fastcgi_ignore_headers Cache-Control Expires Set-Cookie; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
/etc/nginx/nginx.conf | |
fastcgi_cache_path /usr/share/nginx/cache/fcgi levels=1:2 keys_zone=microcache:10m max_size=1024m inactive=1h; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment