New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast close request and continue running php #10093
Conversation
Piwik will not be faster, but perceived performance will be. Website speed with javascript client using this file will be only the latency.
I was bored that piwik.php was ~1/3 of the total website load speed. It's asynchronous load, but better now. BeforeAfterOnly works with php-fpm and mod_php, more than 90% of servers, and using the validation will be no problem with other SAPI. I created a new file for use with the javascript client in websites, so the apps using the API can continue using the normal piwik.php. We only need to show to the website visitors the 204 No response (not 400 Bad Request, ...). Also now don't send Content-type (not necessary for status 204). Tested with and without cookies without problems. If accepted, will be necessary to change the creation of the javascript code created in the config for add to the websites. Directly or validating the SAPI. Thanks for the wonderful Piwik. |
We do have eg bulk tracking where we return a response in json format like how many requests were valid, invalid, ... for this a response is kind of needed. Via the API We could maybe integrate this feature into |
@tsteur interestingly none of the tests are failing with this change - I wonder if some tests should have failed...? |
It's a different file, nothing can fail |
In my websites I use: _paq.push(["setTrackerUrl", u+"webpiwik.php"]); without problems. |
We must distinguish between app tracking and normal website page visits. If we move it to a query parameter, we are moving the solution in to the problem. In normal websites we don't make bulk tracking, no POST,... I created a new file, because it's easier to see what do exactly, don't break and we can make changes and tests. If you prefer, later we can include it, in the piwik.php. Also a good candidate for this optimization, it is when we req an image. We can send the 1x1 gif, close connection and continue processing the data. You will choose if you prefer a new endpoint, or change the method to HEAD ( or image content-type for images) when you only need collect the data. This change don't break anything for app tracking, only add a new endpoint for tracking website page visits. When you want bulk tracking or POST don't send it to this endpoint. If you need more info, only ask me. Thank you |
👍 @joanhey if we want to integrate this change in Piwik it must be done in the main tracking API endpoint as we can only have one API endpoint: |
Piwik will not be faster, but perceived performance will be. Website speed with javascript client using this file will be only the latency.
Included in piwik.php. But not with a query parameter, or we move the solution into the problem. When a client need only the "204 No Response", call to piwik.php with 'HEAD' not 'GET' method. |
@@ -16,6 +16,21 @@ | |||
// Note: if you wish to debug the Tracking API please see this documentation: | |||
// http://developer.piwik.org/api-reference/tracking-api#debugging-the-tracker | |||
|
|||
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$_SERVER['REQUEST_METHOD']
may not always be assigned I think. Probably it is but just to be sure I would maybe add a !empty($...)
We certainly need to have a URL parameter to enable this when wanted instead of Also I think We should check for a URL parameter and we could have an opt in for this in As Piwik 2 aka master branch is in LTS mode and we only merge critical fixes can you issue this PR against the "3.x-dev" branch? |
The next month I'll have time to make the changes |
@joanhey Sounds good let us know how you go |
Thank you for this proposed pull request. Because it was last updated more than one month ago, it is our policy to close pull requests opened for a long time without updates. If you would like to continue work on the pull request, please simply ping us to have it re-opened (after you have pushed a new commit). We hope you understand this and we look forward to seeing an update from you on this pull request or another one! Thanks. |
Piwik will not be faster, but perceived performance will be. Website speed with javascript client using this file will be only the latency.