Don't use a cached file

I have a simple PHP script that runs through Windows task scheduler each day. It reads a CSV file and sends me an email. I have noticed having changed the CSV file it is still processing the old version.

I assume the file is cached somewhere, but I have no idea where. Is there a way to ensure the script is using the current version of the CSV file?

“reads a CSV file”
how are you reading it? Is it a local file read, or a web file read?

Local file reads shouldnt be cached.

Web file reads may be. The typical way to cache-bust these requests is to add a changing non-effective query string parameter, such as file_get_contents("sample.com/file.csv?cachebust=".time());

fopen()
fgetcsv()

The CSV file is in the same directory as the script and the batch file that scheduler runs.

That… would not be possible to cache.

Are you sure you’ve modified and saved that CSV file? (number of times i’ve been working on the wrong copy of a file…)

1 Like

I was about to say yes, having checked again. Then I spotted that it was still pointing to my old localhost directory, and having changed from XAMPP to Laragon they have changed.

If I had a brain, I’d be dangerous!

Thanks Marc

3 Likes

Just one of those things that has tripped me up SO many times…

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.