{"id":98,"date":"2021-05-11T00:32:17","date_gmt":"2021-05-11T00:32:17","guid":{"rendered":"http:\/\/iplocationblock.test\/changelog\/validation-timing\/"},"modified":"2021-05-11T11:55:32","modified_gmt":"2021-05-11T11:55:32","slug":"validation-timing","status":"publish","type":"codex","link":"https:\/\/iplocationblock.com\/codex\/validation-timing\/","title":{"rendered":"Validation timing"},"content":{"rendered":"<p>Normally, a plugin will be loaded at a certain phase during WordPress boot  process and will typically do its jobs after <code class=\"highlighter-rouge\">init<\/code> action hook. It means  that a plugin will be kept waiting until almost all plugins have finished to  be loaded.<\/p>\n<p>But it\u2019s wasteful to give spams and attackers those resources of your server.<\/p>\n<p>The \u201c<strong>Validation timing<\/strong>\u201d at \u201c<strong>Validation rule settings<\/strong>\u201d can help to  drastically reduce load on server especially against brute-force attacks.<\/p>\n<p><!--more--><\/p>\n<h3 id=\"mu-plugins-ip-location-block-muphp\">\u201cmu-plugins\u201d (ip-location-block-mu.php)<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/iplocationblock.com\/wp-content\/uploads\/2021\/05\/ValidationTiming.png\" alt=\"Validation timing\" title=\"Validation timing\" \/><\/p>\n<p>When you select this mode as \u201c<strong>Validation timing<\/strong>\u201d, this plugin will install  <code class=\"highlighter-rouge\">ip-location-block-mu.php<\/code> into your <code class=\"highlighter-rouge\">\/wp-content\/mu-plugins\/<\/code> which is for  <a href=\"https:\/\/codex.wordpress.org\/Must_Use_Plugins\" title=\"Must Use Plugins &laquo; WordPress Codex\">must-use plugins<\/a>. It means that this plugin will be loaded and  execute validation prior to other typical plugins.<\/p>\n<p>Note that in case of multisite, <code class=\"highlighter-rouge\">ip-location-block-mu.php<\/code> will be called on every  site but doesn\u2019t affect a site where IP Location Block is not activated.<\/p>\n<h4 id=\"restrictions\">Restrictions<\/h4>\n<p>As you can find the order of execution in <a href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\" title=\"Plugin API\/Action Reference &laquo; WordPress Codex\">action reference<\/a>,  mu-plugins are processed prior to theme setup. Consequently, the following  two restrictions would be raised.<\/p>\n<ol>\n<li>\n<p><strong><a href=\"https:\/\/www.ipgeoblock.comhttps:\/\/iplocationblock.com\/?codex-category=actions-and-filters\" title=\"Filter hooks | IP Location Block\">Custom filter hooks<\/a> in <code class=\"highlighter-rouge\">functions.php<\/code> does not work<\/strong><br \/> It is bacause the <code class=\"highlighter-rouge\">functions.php<\/code> in the theme folder would not have been parsed when this plugin do its jobs. In this case, you <strong>must<\/strong> put your own code into <code class=\"highlighter-rouge\">drop-in.php<\/code> which should be placed in the geolocation database  folder. You can find <code class=\"highlighter-rouge\">drop-in-sample.php<\/code> as a sample in this plugin\u2019s  folder, i.e. <code class=\"highlighter-rouge\">\/wp-content\/plugins\/ip-location-block\/wp-content\/ip-geo-api\/<\/code>. Please rename it to <code class=\"highlighter-rouge\">drop-in.php<\/code> and put it into your  <a href=\"https:\/\/iplocationblock.com\/codex\/local-database-settings\/\" title=\"How to fix permission troubles? | IP Location Block\">Geolocation API folder<\/a> when you use it.<\/p>\n<\/li>\n<li>\n<p><strong><a href=\"https:\/\/iplocationblock.com\/codex\/customizing-the-response-code-and-message\/#human-friendly-error-page\" title=\"Customizing the response | IP Location Block\">Human friendly error page<\/a> is unavailable<\/strong><br \/> It is because the theme setup would not have finished when this plugin do  its jobs. It means that when you select <code class=\"highlighter-rouge\">404 Not Found<\/code> as <strong>Response code<\/strong>, <code class=\"highlighter-rouge\">404.php<\/code> in your theme folder might not work. In this case, you <strong>must<\/strong>  save your human friendly error page as a static file. If you want to show a  human friendly page for blocked visitors, you <strong>must<\/strong> configure as follows:<\/p>\n<ul>\n<li>Show your 404 page. (e.g. <code class=\"highlighter-rouge\">http:\/\/example.com\/wp-content\/themes\/your-theme\/404.php<\/code>)<\/li>\n<li>Save the HTML contents in the page as a new <code class=\"highlighter-rouge\">404.php<\/code> using your browser (e.g. \u201cView page source\u201d with right click). It means that the file consists of not PHP codes but static HTML codes.<\/li>\n<li>Place it into your theme folder. A child theme is recommended to keep the  original file in your parent theme folder.<\/li>\n<li>In case of <code class=\"highlighter-rouge\">403 Forbidden<\/code>, it\u2019s almost the same but just save the page as <code class=\"highlighter-rouge\">403.php<\/code> and change the message as you like.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/iplocationblock.com\/wp-content\/uploads\/2021\/05\/404NotFound.png\" alt=\"Human friendly error page\" title=\"Human friendly error page\" \/><\/p>\n<h4 id=\"performance\">Performance<\/h4>\n<p>The more plugins you have, the lower site speed you get.<\/p>\n<p>You may be interested in the benchmark of the two \u201c<strong>Validation timing<\/strong>\u201d. As with <a href=\"https:\/\/iplocationblock.com\/impact-on-server-load-caused-by-brute-force-attacks\/\" title=\"Impact on server load caused by brute-force attacks | IP Location Block\">the previous report<\/a>, the test environment and sample  plugins are showen blow:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">Category<\/th>\n<th style=\"text-align: left\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Hardware<\/td>\n<td style=\"text-align: left\">MacBook Pro \/ 2.8GHz Core i7 \/ Memory 16GB<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Software<\/td>\n<td style=\"text-align: left\">OS X 10.9.5 \/ MAMP 3.5.2 (Apache 0.2.2.29, PHP 5.6.10)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">WordPress<\/td>\n<td style=\"text-align: left\">4.6-ja \/ Site Language: English<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img decoding=\"async\" src=\"https:\/\/iplocationblock.com\/wp-content\/uploads\/2021\/05\/PluginsDashboard.png\" alt=\"Plugins Dashboard\" title=\"Plugins Dashboard\" \/><\/p>\n<p>The following tables show comparisons between the two mode of \u201c<strong>Validation  timing<\/strong>\u201d against the each target using <a href=\"https:\/\/httpd.apache.org\/docs\/current\/programs\/ab.html\" title=\"ab - Apache HTTP server benchmarking tool - Apache HTTP Server Version 2.4\">ApacheBench<\/a> for 60 seconds. As you  can see, the number of requests have become to be handled more than twice with  <code class=\"highlighter-rouge\">\"mu-plugins\" (ip-location-block-mu.php)<\/code>.<\/p>\n<h5 id=\"xmlrpcphp\">xmlrpc.php<\/h5>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">\u00a0<\/th>\n<th style=\"text-align: right\">init action hook<\/th>\n<th style=\"text-align: right\">mu-plugins<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Complete Reqs<\/td>\n<td style=\"text-align: right\">271<\/td>\n<td style=\"text-align: right\">595<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Reqs\/sec [#\/sec]<\/td>\n<td style=\"text-align: right\">4.51<\/td>\n<td style=\"text-align: right\">9.89<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Time\/req [msec]<\/td>\n<td style=\"text-align: right\">221.877<\/td>\n<td style=\"text-align: right\">101.093<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 id=\"xmlrpcphp-sysmulticall\">xmlrpc.php (sys.multicall)<\/h5>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">\u00a0<\/th>\n<th style=\"text-align: right\">init action hook<\/th>\n<th style=\"text-align: right\">mu-plugins<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Complete Reqs<\/td>\n<td style=\"text-align: right\">273<\/td>\n<td style=\"text-align: right\">593<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Reqs\/sec [#\/sec]<\/td>\n<td style=\"text-align: right\">4.53<\/td>\n<td style=\"text-align: right\">9.87<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Time\/req [msec]<\/td>\n<td style=\"text-align: right\">220.988<\/td>\n<td style=\"text-align: right\">101.315<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 id=\"wp-loginphp\">wp-login.php<\/h5>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">\u00a0<\/th>\n<th style=\"text-align: right\">init action hook<\/th>\n<th style=\"text-align: right\">mu-plugins<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Complete Reqs<\/td>\n<td style=\"text-align: right\">280<\/td>\n<td style=\"text-align: right\">619<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Reqs\/sec [#\/sec]<\/td>\n<td style=\"text-align: right\">4.66<\/td>\n<td style=\"text-align: right\">10.28<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Time\/req [msec]<\/td>\n<td style=\"text-align: right\">214.395<\/td>\n<td style=\"text-align: right\">97.247<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 id=\"wp-adminadmin-ajaxphp\">wp-admin\/admin-ajax.php<\/h5>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">\u00a0<\/th>\n<th style=\"text-align: right\">init action hook<\/th>\n<th style=\"text-align: right\">mu-plugins<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Complete Reqs<\/td>\n<td style=\"text-align: right\">229<\/td>\n<td style=\"text-align: right\">551<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Reqs\/sec [#\/sec]<\/td>\n<td style=\"text-align: right\">3.81<\/td>\n<td style=\"text-align: right\">9.17<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Time\/req [msec]<\/td>\n<td style=\"text-align: right\">262.588<\/td>\n<td style=\"text-align: right\">109.039<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","class_list":["post-98","codex","type-codex","status-publish","hentry","codex-category-faq"],"_links":{"self":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/codex\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/codex"}],"about":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/types\/codex"}],"replies":[{"embeddable":true,"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/comments?post=98"}],"wp:attachment":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/media?parent=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}