- Issue created by @bogdan.dinu
Redirects to source file get cached indefinitely and if you change the source file you need to do a cache rebuild in order for the media canonical link to redirect you to the new file.
1. Install Media link enhancements and enable redirects.
2. Instal a media file replace contrib module (media_entity_file_replace for example).
3. Create a new file media (file1.txt) and access the canonical url. This will redirect you to sites/default/files/2024/10/file1.txt.
4. Replace the file file1.txt with file2.txt.
Expected result:
The media canonical url will redirect you to the new file: sites/default/files/2024/10/file2.txt.
Actual result:
The media canonical url redirects to the old file: sites/default/files/2024/10/file1.txt.
The MediaLinkEnhancementsController uses a TrustedRedirectResponse which extends CacheableSecuredRedirectResponse and does not set any cache contexts or cache tags.
Setting the url.site cache context and the media:[id] cache tag ensures that the redirect is updated when the media is updated.
Active
1.0
Code