| 1 | --- |
| 2 | title: "HX-History-Restore-Request" |
| 3 | description: "Indicates history navigation (back/forward)" |
| 4 | --- |
| 5 | |
| 6 | The `HX-History-Restore-Request` request header is set to `true` when the user navigates back or forward in history. |
| 7 | |
| 8 | htmx restores the previous state without a full page reload. Use this to skip side effects during history restoration. |
| 9 | |
| 10 | ## Example |
| 11 | |
| 12 | Skip analytics for restored pages. |
| 13 | |
| 14 | ```python |
| 15 | if request.headers.get('HX-History-Restore-Request'): |
| 16 | # Don't log analytics or run side effects |
| 17 | return render_content() |
| 18 | else: |
| 19 | log_page_view() |
| 20 | return render_content() |
| 21 | ``` |