How to prevent leaflet from asking no-cache?

I am using OSM’s tile servers, which have this tile policy.

In the “technical usage requirements” it states that my web app must NOT send no-cache headers. In the note it also says that modern web browsers pass the checks, but my app does send both “Cache-Control: no-cache” and “Pragma: no-cache”.

I did find an option in leaflet to send the Referer header, but there doesn’t seem to be a similar option for these cache headers.

It’s not something you can control in that way but you don’t need to - leaflet will never add such headers. The browser might but only in response to a specific user action and not by default.

In my case (which brought me here) I was debugging with Microsoft Edge. The “Network” tab of the debug window has an option “Disable cache.” I had enabled this long ago, chasing down some other network confusion, so I would be sure to see all network traffic. With this option enabled, Edge was forcing “Cache-Control: no-cache” and “Pragma: no-cache,” which is exactly what OpenStreetMap says not to do.

When I unchecked “Disable cache” in the Edge debugger, the offending header content disappeared. I believe other major browsers have similar debug options.

Thanks @TomH for mentioning the browser might be doing this. Big help for me!