Permalink overhead

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?

There is an option already.

Are you looking for something else?

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.

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.

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).

in phpbb3 importer script they already using it

https://github.com/discourse/discourse/blob/master/script/import_scripts/phpbb3/importers/permalink_importer.rb#L32

Hope it can help you :slight_smile:

2 Likes

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.

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:

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

https://github.com/discourse/discourse/pull/4501

3 Likes

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

3 Likes