Capture returned data and persist it to a disk based cache store for a configurable amount of time.
Additional Requirements:
Nginx
Logged In Cookie
Nginx includes a FastCGI module which has directives for caching dynamic content that are served from the PHP backend. Setting this up removes the need for additional page caching solutions like reverse proxies (think Varnish) or application specific plugins. Content can also be excluded from caching based on the request method, URL, cookies, or any other server variable.
Credits to @eva2000 @hungphutho @MattW and @Floren for their guidance when I started this
.
For centminmod based server, above this line:
Assuming you don't modify the default xenforo cookie prefix which is xf_.
3rd: From this
include fastcgi_params;
For centminmod based server, add above this line:
Modify template helper_login_form and login_bar_form.
Replace:
With this:
FAQ:
What you are looking for is something that says "X-Cache-Status HIT"
HIT means that fastcgi is working.
MISS or anything else means that the page was not served from cache.
Additional Requirements:
Nginx
Logged In Cookie
You must be registered for see images
Nginx includes a FastCGI module which has directives for caching dynamic content that are served from the PHP backend. Setting this up removes the need for additional page caching solutions like reverse proxies (think Varnish) or application specific plugins. Content can also be excluded from caching based on the request method, URL, cookies, or any other server variable.
Credits to @eva2000 @hungphutho @MattW and @Floren for their guidance when I started this
- 1st: Install required
You must be registered for see links, to have persistent cookie for Login Users.
- 2nd: Add this code into your Nginx Config / nginx.conf, below http { block
For centminmod based server, above this line:
You must be registered for see links
Assuming you don't modify the default xenforo cookie prefix which is xf_.
Code:
### Start FastCGI Cache ################
#map $http_user_agent $mobile_request {
# default 0;
# ~*android|ip(hone|od)|windows\s+(?:ce|phone) 1;
# ~*symbian|sonyericsson|samsung|lg|blackberry 1;
# ~*mobile 1;
#}
map $http_cookie $nocachecookie {
default 0;
~xf_fbUid 1;
~xf_user 1;
~xf_logged_in 1;
#~xf_style_id 1;
}
map $request_uri $nocacheuri {
default 0;
~^/register 1;
~^/login 1;
~^/validate-field 1;
~^/captcha 1;
~^/lost-password 1;
~^/two-step 1;
}
fastcgi_cache_path /tmp/nginx_fastcgi_cache levels=1:2 keys_zone=fastcgicache:200m inactive=30m;
### End FastCGI Cache ################
3rd: From this
You must be registered for see links
, add after this code:include fastcgi_params;
For centminmod based server, add above this line:
You must be registered for see links
Code:
### fastcgi_cache start ###
fastcgi_cache_methods GET;
#fastcgi_cache_key $scheme$request_method$host$request_uri$mobile_request;
fastcgi_cache_key $scheme$request_method$host$request_uri;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache fastcgicache;
fastcgi_no_cache $nocachecookie $nocacheuri;
fastcgi_cache_bypass $nocachecookie $nocacheuri;
fastcgi_cache_valid 200 301 302 303 304 404 15m;
add_header X-Cache-Status $upstream_cache_status;
### fastcgi_cache end ###
- 4th: Save and then restart Nginx and PHP-FPM. nprestart for centminmod.
- 5th: To have xf_user cookie persist on every Login Users.
Modify template helper_login_form and login_bar_form.
Replace:
HTML:
<label class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" tabindex="3" /> {xen:phrase stay_logged_in}</label>
With this:
HTML:
<input type="hidden" name="remember" value="1" />
FAQ:
- Benefits? Same as Varnish and LiteSpeed Full Page Caching.
- This implementation works similar with [bd] Cache Cache Pages and [DBTech] DragonByte Optimise Guest Full Page Caching but works way BETTER, so disable it when you have those addon.
- How to verify if fastcgi_cache is working properly?
What you are looking for is something that says "X-Cache-Status HIT"
HIT means that fastcgi is working.
MISS or anything else means that the page was not served from cache.
