I have done a Web-page search function.
The search is initiated by the foreground, and the search results are returned in the background.
Hit the folder search, and folders under the number of files (more than 20,000), the search time is very long (2 minutes or so to get results), sometimes I have no patience to wait, on the point stop search.
// 终止搜索 stopSearch: function(){ console.log('xhr请求集合: ' , this.reqList); for (var i = 0; i < this.reqList.length; ++i) { if (this.reqList[i].readyState !== 0 || this.reqList[i].status !== 200) { this.reqList[i].abort(); } } }
After clicking Stop Search, it is true that the foreground is stopped:
But the background php script is still running (and I set the PHP script to run the maximum time of 3min), each page refresh and so long (1min more), this is still relatively honest case (only launched a), if the bird fire, the mouse mad point, that estimate I had to restart the server ... Khan (The following is the result of the mad point, only point two or three times, the longest request time will reach 5min ... )!
Is there any way to terminate the operation of the background PHP script when the request is stopped?
Reply content:
I have done a Web-page search function.
The search is initiated by the foreground, and the search results are returned in the background.
Hit the folder search, and folders under the number of files (more than 20,000), the search time is very long (2 minutes or so to get results), sometimes I have no patience to wait, on the point stop search.
// 终止搜索 stopSearch: function(){ console.log('xhr请求集合: ' , this.reqList); for (var i = 0; i < this.reqList.length; ++i) { if (this.reqList[i].readyState !== 0 || this.reqList[i].status !== 200) { this.reqList[i].abort(); } } }
After clicking Stop Search, it is true that the foreground is stopped:
But the background php script is still running (and I set the PHP script to run the maximum time of 3min), each page refresh and so long (1min more), this is still relatively honest case (only launched a), if the bird fire, the mouse mad point, that estimate I had to restart the server ... Khan (The following is the result of the mad point, only point two or three times, the longest request time will reach 5min ... )!
Is there any way to terminate the operation of the background PHP script when the request is stopped?
No, all you can do is optimize your search performance.
Only from optimized search performance up and down. The HTTP protocol does not have a request to terminate the request to the background, and if the front-end server is Nginx, the PHP application server does not even know that the client has disconnected.
In this case, you can only start by optimizing the background.