How can Discourse make POST instead of DELETE for "smart" CDN?

(Robert Z) #1

To delete a topic, Discourse makes a request like:


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.

(Jeff Atwood) #2

Why don’t you use the built in CDN support, available by editing app.yml? See the #howto topic.

(Robert Z) #3

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.

(Robert Z) #4

Could anyone point me how-to? Or give me some clue? I can modify the code myself.

(Robert Z) #6

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.

BTW, I’ve made a patch of code to use POST for DELETE at GitHub - coin8086/discourse-ajax: Discourse Ajax patch for CDN/server that doesn’t support HTTP DELETE method. You see it’s not difficult.

(Sam Saffron) #7

If you want to submit a pull request with this option, default OFF, then we are open to it.