Permalink overhead


(Jay Pfaffman) #1

I’m updating bbpress.rb to have it deal with attachments (now it inserts a link to the attachment on the original site) and create permalinks for the old URLs.

The old format is `/forums/topic/slug’. For anyone who knows how to write an Nginx redirect, it’s pretty simple to redirect that to /t/slug and be done with it. OTOH at this particular instant, it is faster for me to add code to the importer to create those permalinks.

Question: Is there any reason not to create a permalink for every topic?


(Vinoth Kannan) #2

There is an option already.

Are you looking for something else?


(Jay Pfaffman) #3

No, that’s what I’m doing, though rather than having to enter the rails console and find a way to do a Permalink.create for every URL, I’m doing that automatically in the importer. Normal People should not be subjected to the Rails console. :slight_smile:

My current hypothesis is that it might actually be (a very tiny bit) better to have Discourse do the redirects than to get Nginx to do it, as adding that redirect will cause Nginx to have to process it on every url request.


(Rafael dos Santos Silva) #4

Actually, doing it on Nginx should be way faster than doing in Discourse. The problem is that Discourse is way easier, friendly and portable, while Nginx should be treated in a case-by-case basis.


(Jay Pfaffman) #5

Thanks, @falco. I’ll take that as a “no.” There’s no reason not to have the importer add a redirect for every topic, and no reason to make it easy to turn off that functionality (e.g., by setting an environment variable).


(Vinoth Kannan) #6

in phpbb3 importer script they already using it

Hope it can help you :slight_smile:


(Rafael dos Santos Silva) #7

Maybe having an easy turn off is a good thing. If I were doing a special custom import, I would prefer the nginx redirect route.

But having the code in a reusable script that doesn’t make me do it every time is very valuable.


(Jay Pfaffman) #8

Done. But, if it’s you that we’re talking about, you can just put a # in the front of the create_permalinks call in execute. :slight_smile:


(Rafael dos Santos Silva) #9

One to turn it all off (default on) looks good for me.


(Jay Pfaffman) #10

(Sam Saffron) #11

Nope, I can not think of any performance reasons to avoid permalink creation, it does an indexed lookup which is very cheap.