Long Polling is a technique that simulates a server unavailability to keep an HTTP connection open. This technique was created from the need to communicate in real time with a web server.
Context
With the need to get real-time data from the server, developers once created routines that sent a request from time to time (as you described it yourself) to "ask" whether there were changes to the application's data model. If there were, the request response would contain this data and then it could be updated in the application.
This type of routine consumed a large amount of resources when the application tended to be scalable (growing fast).
Let's simulate:
Imagine a page that sends an AJAX request every 5 seconds to a specific endpoint to find out if there have been any changes to notifications, for example.
This does not become a problem with very few users simultaneously connected. But let's say the application grows from 10 users to 100 users simultaneously connected.
Let's think bigger. Imagine 1,000 connected users.
In 5 seconds, 1,000 requests will be sent to the same endpoint . After another 5 seconds, plus 1,000, and so on.
Depending on the architecture of the application, this begins to overload the server. Specifically that endpoint .
"The solution" - Long Polling
When a client makes a request, the server simulates a data unavailability and causes the HTTP request to be unresponsive as long as there are no changes to the application data model.
Does this solve the problem? Yes and no.
Yes, why it is not necessary to be sending requests of times and times to check these changes.
No, why did this cause another performance problem. HTTP requests were not specified for this. Extending an HTTP request may "seem" to solve the problem of the request quantity sent to the endpoint , but in fact it also consumes a lot of resource just because it is being used inappropriately.
The real solution - WebSockets
I wrote a post about WebSockets and its implementation in Java (but it has implementations for almost all current languages).
I suggest you take a look at why I go into detail with the details and also give you practical examples to reproduce there in your home.
Real-time communication with WebSockets
Anyway ..
Focus your study on WebSockets implementations and be happy with real-time real-time communication.