jetbrains logo Getting Started with HTMX - Complete

10. Client Long Polling

Polling can be a valuable technique to keep clients informed of changes to critical data. Instead of having your users sit there refreshing a page, the page can periodically call the server to retrieve information. This technique becomes incredibly potent when the response is cached, allowing you to update data once, cache it on the first request, and have all subsequent clients benefit from the result.

HTMX allows you to provide an hx-trigger based on a time interval using the value of every 2s. Thus, the page will call the server every 2 seconds to retrieve updates. You may have already noticed the values changing on this page.


Apple
$109.00
Opened @ $100.00
Empire
$791.00
Opened @ $1000.00
Rebel
$12.00
Opened @ $10.00