I just enabled S3 uploads on my Discourse instance, configured with a Cloudfront CDN. I just tested uploading an image and a PDF file as attachments into posts and they are correctly uploaded into the S3 bucket. However, inspecting the page where both are shown, I see that the PDF does not use the CDN link, but the image does.
For the image, the img src points to the CDN, which the browser uses to load the thumbnail.
For the PDF file, the link src points to a relative URL (/uploads/short-url/xxxxxxxxxxxxx.pdf), which seems to redirect to the file in my actual S3 bucket (not the CDN).
Is this expected? This is my first time using a CDN, so perhaps one typically doesn’t serve larger files through it? I just want to make sure that I have all my settings correct and working before migrating all older posts to S3.
I think that your need to rebake the posts. The ones uploaded before your added the CDN are not automatically updatedmRebake all posts matching a pattern, (it might be easier to just rebake all of them)
I just rebaked all posts and found no change. After rebaking, I created some test posts again. To re-cap what I’m seeing (and looks like what @Richie sees)
-An image in a post correctly links to the CDN for the image displayed inline in the post.
-For the image however, the “download” link (lower right when viewing the image full size), links to a short-url, which redirects to my S3 bucket (not the CDN)
-For a PDF upload, the link links to a short-url, which redirects to my S3 bucket (not the CDN).
It appears that any time a short-url is used, the CDN is not used in the redirection.
For my Discourse setup, I am using S3 for both uploads and backups. I have not moved all of my existing uploads to S3 yet (will do once I get over this issue). I also do not have secure uploads enabled.
Thanks for reporting this, we will have a look next week and sort out any missing CDN bypasses that are left. We should always where possibly reach to the CDN with the caveat that if you have secure uploads enabled we can not do so easily.