Append date to file name in order to solve Firefox caching issue?

Hello everyone,

I’ve got an ugly problem with Firefox and our kirby based internal website we re using here at our workplace.

In panel there is a possibility to replace a file. That’s working fine. The problem is, when some colleagues are downloading file from frontend, they’re “downloading” version Firefox has cached.

I have this setup for downloading a file:

<a href="<?php if($file = $result->documentselect()->toFile()) {echo $file->url();} ?>" download="<?php $file->filename(); ?>">

I had an idea, that it may help to slightly vary the filename everytime the user is downloading it to “trick” firefox thinking it’s a completely new file. I tried this solution with appending the date:

... download="<?php echo date('ymd'); ?>-<?php $file->filename(); ?>"...

But the only output I’m getting is date without the filename with extension. When I’m removing date line it shows filename.

Do anyone has an idea how to fix this? :slight_smile:

This <?php $file->filename(); ?> doesn’t echo anything, should be

<?= $file->filename(); ?>
1 Like

Damn that was simple. I’ve always thought there is no difference between <?= and <?php except first one is shorter to write.

<?= is short for <?php echo

1 Like