When working with Power Query to fetch data from a web source, caching can sometimes prevent you from retrieving the most up-to-date file. This can be caused by either browser caching or server-side caching mechanisms.

To ensure you’re always getting the latest version of your file, you can append a random query parameter to the file URL. This forces Power Query to treat each request as unique, bypassing any cached versions.

Solution

Use the following Power Query (M) script:

let
     Source = Csv.Document(Web.Contents("https://example.domain.com/file.csv?" & Number.ToText(Number.RoundDown(Number.RandomBetween(1, 1000000)))),
         [Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.None]),
     #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
 in
     #"Promoted Headers"

How It Works

  • The Web.Contents function fetches the CSV file from the provided URL.
  • The Number.RandomBetween(1, 1000000) generates a random number.
  • This random number is appended as a query parameter, ensuring each request is treated as a unique request by the server.

Benefits

  • Prevents stale data from being loaded due to caching.
  • Ensures your Power Query reports always reflect the latest file updates.
  • Works seamlessly without needing server-side changes.

By implementing this approach, you can confidently refresh your Power Query data without worrying about outdated cached files.