In a Support discussion titled How can Discourse make POST instead of DELETE for “smart” CDN?, louirobert explains that their CDN (a “smart” type common in China, like Aliyun CDN) doesn’t support the HTTP DELETE method, which Discourse uses to delete topics (e.g., DELETE http://example.com/t/123). They note Rails can emulate DELETE via POST with a _method parameter and ask how to configure Discourse to do this. codinghorror suggests using Discourse’s built-in CDN support via app.yml, but louirobert clarifies their vendor doesn’t support that method and highlights the benefit of smart CDNs caching user-uploaded images. louirobert requests guidance or code pointers to implement the change themselves. In post 6, they propose adding an admin panel option to allow POST instead of DELETE — useful not only for CDNs but also for proxies/servers lacking DELETE support — and share a working patch at github.com/coin8086/discourse-ajax. sam responds positively, inviting a pull request for this feature, to be disabled by default. The core issue is compatibility with restrictive CDNs, especially in regions with limited vendor options, and the community is open to a configurable solution.
However my CDN doesn’t support DELETE method, but only GET, HEAD, POST, and OPTIONS. I remember that Rails can make a POST request instead of DELETE by adding a “_method” request variable. So how can I config Discourse to do that?
BTW, my CDN is a kind of “smart” CDN that I just tell it my domain name and do some config on DNS without settings on Discourse part and it will speed my site by caching small files like images and css automatically. So in a word, all client requests, including the DELETE one, go through the CDN server first. Then the CDN server decides to return cached files directly or to go further to my original server next.
I saw that. But my CDN vendor, which is also my host vendor, doesn’t support that way. BTW, I’m from China, and my choices are limited. What’s more, that way also has an advantage that it can speed the user uploaded images like avatars.
I think it’s great to make an option in admin panel to allow POST for DELETE. This is not only for CDN but may also for servers, proxies that don’t support DELETE. And it’s especially useful for the kind of smart CDN, which can speed up all images, including user uploaded ones, but may not support DELETE method. Aliyun CDN, one of the biggest in China, is just such an example.