Hello everyone, I used CFW to create a website entry page, used it to receive all the inbound traffic of the website, and processed it in two steps: first, use fetch to send each visitor to the origin server for statistics, and then immediately redirect to another website A cached html page.
The problem now encountered is that the origin server php statistics are far less than CFW statistics. For example, the number of Requests counted by CFW is 1.23K, and the number of Subrequests is also 1.23K, but the number counted by origin server PHP is less than 1K.
fetch sets keepalive=true to ensure that the request can be sent before redirect. I checked the PHP program many times to make sure that all visitors to the entry page are recorded. In addition, all visitors come from chrome for android browsers of chrome46 or above, so there should be no browser compatibility issues.
What is the reason for the difference of more than 20% in the 2 stats? Where should I check? Do you have any comments?
addEventListener(“fetch”, (event) => {
event.respondWith(handle(event))
});async function handle(event){
const request = event.request;
var init = {
method: “POST”,
headers: {‘Content-Type’: ‘application/x-www-form-urlencoded’},
body: ‘data=datastr’,
keepalive: true
}
const phpurl = “https://a.example.com/deal.php”;
const phpRequest = new Request(phpurl, request);
fetch(phpRequest,init);const newInt = {status: 302} const redirecturl = "https://b.example.com/page.html"; const newResponse = new Response('',newInt); newResponse.headers.append('Location',target_url); return newResponse;
}