Closed mrmmg closed 4 years ago
You would not be able to track it using a middleware, since the middleware (and the PHP code in general) won't be executed on a cache-hit - since the content is delivered directly by the webserver, we'll never hit PHP.
The only way you can really do it, is to either execute an ajax call (which doesn't use any form of caching), or track the visits using tools like Matomo or similar (Which technically does the same with a PHP file that gets information from the request).
@lucasRolff Thank you, I changed my method to an ajax call and it's worked.
Hello Thanks for the good package you have prepared for Laravel, I used this package in my project but there is a strange problem with it. First, read the following scenario: I have written a custom middleware to track my site visits, please see the following snippet:
routes (web.php)
my middleware:
And problem statement:
When the site is visited for the first time, nothing is cached and my custom middleware is executed, but for the next time, the same middleware will not be executed at all.
I have disabled the entire cache process and the problem is solved!!!
Can you help me solve this problem?