May not be the issue but had this problem with a site i inherited from other developer. Spent hours trying different solutions.
Eventually traced the problem to the fact the site was running on a vps behind an nginx proxy which was caching everything.
Turned off proxy caching and all was well.
Caution should be advised here, such technique is not in the interest of the website user. If this is a one-time thing one could add a ?r=1 (r for revision) parameter, instead of dynamically generating a new practically-random parameter every time the page is loaded
The 1st technique you suggested is way better than the 2nd, taking in consideration the user's interest
If this is in development only, people usually do CTRL+F5 to refresh without cache