civicrm/file/imagefile serving up wrong images
I'm getting a really strange bug in CiviCRM 5.3.1 (Drupal 7.59). I tried updating to 5.4.1 and have the same issue.
This is our upcoming events page. This is a Drupal Views page that is pulling in CiviEvents. We have a custom field on CiviEvents of type file. We use this field to upload an image associated with the event that gets pulled into the upcoming events page. It is an optional field, which if not used, Drupal will serve up a default image instead. The CiviCRM event's file field is served from /civicrm/file/imagefile?id=X&eid=Y
If I go visit a contact view page then go back and refresh the event page, /civicrm/file/imagefile?id=X&eid=Y is now serving up the last viewed contact's image instead of the image uploaded to the event's custom file field.
I can keep refreshing this page indefinitely and it will keep showing the contact image instead of the image tied to the event. If I logout and log back in and view the event page, images are getting pulled correctly again.
This isn't directly related to visiting /civicrm/contact/view. We have a public CiviCRM profile that allows users to update their contact information (including their contact image). I've noticed the same issue happens if I login and visit this profile (/civicrm/profile/edit) before visiting the Upcoming Events page.
I was adviced in Mattermost to check apache request logs when the images are pulling correctly, as well as after visiting a contact view page (or the profile page mentioned above) to compare the requests.
REQUEST1 (displaying event images correctly)
192.0.0.199 - - [05/Sep/2018:13:52:33 -0700] "GET /civicrm/file/imagefile?id=817&eid=32 HTTP/1.1" 200 91252 "https://www.clinicaltmssociety.org/events" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
192.0.0.199 - - [05/Sep/2018:13:52:33 -0700] "GET /civicrm/file/imagefile?id=816&eid=30 HTTP/1.1" 200 19962 "https://www.clinicaltmssociety.org/events" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
192.0.0.199 - - [05/Sep/2018:13:52:33 -0700] "GET /civicrm/file/imagefile?id=814&eid=33 HTTP/1.1" 200 11621 "https://www.clinicaltmssociety.org/events" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
REQUEST2 (displaying contact images on events page, instead of the event images)
192.0.0.199 - - [05/Sep/2018:13:53:29 -0700] "GET /civicrm/file/imagefile?id=817&eid=32 HTTP/1.1" 200 516963 "https://www.clinicaltmssociety.org/events" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
192.0.0.199 - - [05/Sep/2018:13:53:29 -0700] "GET /civicrm/file/imagefile?id=816&eid=30 HTTP/1.1" 200 516963 "https://www.clinicaltmssociety.org/events" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
192.0.0.199 - - [05/Sep/2018:13:53:29 -0700] "GET /civicrm/file/imagefile?id=814&eid=33 HTTP/1.1" 200 516963 "https://www.clinicaltmssociety.org/events" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
More details can be found in the Mattermost discussion below:
https://chat.civicrm.org/civicrm/pl/xrkg8rf95ffruyfmc9fko8zifw