Persistent links for attachments

AI-generated summary

tfoote highlights an issue with broken external links to attachments on Discourse after a CDN change, despite internal links being updated. As Discourse is increasingly used for managing working groups and hosting authoritative documents (like the TSC Charter), stable, persistent URLs for attachments are needed to support external citations. Two solutions are proposed: (1) serving attachments via local URLs that redirect to the current CDN endpoint (ensuring consistency but adding a small redirect overhead), or (2) extending the admin console’s Permalink feature to support attachments directly, allowing manually created stable links for high-value files. An example is given where a GitHub documentation PR had to be updated solely due to the CDN URL change, even though the document content remained unchanged. The ideal solution would allow attachments to be accessed via a persistent path like https://discourse.ros.org/uploads/... that transparently redirects to the correct CDN location, preserving external references without manual intervention.

One of the patterns that we’re developing is to use Discourse categories for working group management. It’s a great way to have smaller group discussions that are publicly visible and provide resources to the community. To that end we’ve been attaching documents to the posts that are important to the group’s communications etc. Sometimes things just don’t fit into post text.

As the knowlegebase has been growing up these semi-authoritative documents have become referenced externally. This has worked well until recently the CDN was changed for our discourse instance. And now all of the links to the attachments are broken. It would be great to support having a stable link to the attachments for reference/citation.

When the CDN was updated all the embedded links in the posts were correctly updated. But the external references were broken because the only links to the attachments are directly to the CDN endpoint.

It would be great to provide a persistent url so that external references to the attachments do not change.

There are two approaches that jumped out to me as being possible appraches. The first is to advertise a local url as the link. But it is just an http style redirect to the appropriate CDN endpoint so that any agent fetching the URL will then just move on and fetch it from the CDN. This incurs the cost of a small page load for every link but gives more control/consistency.

As an alternative, a possible way that would not work as universally, but could be managed for high value items would be to allow creating Permalinks in the admin console to the high value attachments. Right now Permalinks can go to a Post, Topic, or Category by ID. If that was extended to support Attachments we could use the explicitly created permalink for external citation.

As an example of this our TSC Charter is attached to this post:

It was orginally available from: This Page Was Not Found • Discourse-cdn-sjc2.com but with the CDN change it’s now posted at: https://aws1.discourse-cdn.com/standard17/uploads/ros/original/2X/5/51feec4148e3c458856526ad4bcf44d9912c4c9a.pdf

It would be great to have it work at a url like:
https://discourse.ros.org/uploads/ros/original/2X/5/51feec4148e3c458856526ad4bcf44d9912c4c9a.pdf which would then redirect to the appropriate CDN endpoint.

An example of a place that we want to externally reference the document can be found here: Update link to charter doc by gerkey · Pull Request #282 · ros2/ros2_documentation · GitHub where we had to update the link for the new CDN despite the content not changing.

1 Like