Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return HTTP 301 instead of HTTP 302 #746

Closed
Laurendus opened this issue May 1, 2020 · 10 comments · Fixed by #792
Closed

Return HTTP 301 instead of HTTP 302 #746

Laurendus opened this issue May 1, 2020 · 10 comments · Fixed by #792
Labels
Milestone

Comments

@Laurendus
Copy link

Summary

When using the docker setup generated links return a HTTP 302 temporary redirect. This is bad for SEO so I would like shlink to be able to redirect with a HTTP 301.
If I haven't overseen something this would IMO be a small but great feature enhancement.

To respect use cases which do not contain a permanent redirect it could also be a configuration option.

If you do not have the time to implement this feature you could also point me to the relevant files and I will have an inexperienced try at it.

@acelaya
Copy link
Member

acelaya commented May 1, 2020

I'm afraid this would make no sense. Browsers would cache the redirect and you would stop tracking visitors.

@acelaya acelaya closed this as completed May 1, 2020
@acelaya
Copy link
Member

acelaya commented May 1, 2020

Actually, I have just quickly checked, and it looks like other URL shorteners are returning permanent redirects.

For me it breaks a bit the purpose, as you would not be getting real visit stats. Any returning user would count just as one visit.

Also, considering Shlink lets you edit the destination URL, this would make it have a weird behavior.

But I will keep this open, and investigate a little further.

It will also help me see interest on the feature.

@acelaya acelaya reopened this May 1, 2020
@Laurendus
Copy link
Author

I just investigated the behaviour of bit.ly as an example:
bit.ly returns a HTTP 301 along with a Cache-Control Header with a value of 90 seconds.
To me it seems as if this header is used by browsers to control the caching of the permanent redirect.

In my opinion a timeframe of 90 seconds would be acceptable for visit stats and a temporary inconsistent redirect behaviour when the destination was changed.

Maybe you could implement permanent redirects with a Cache-Control header as a configuration option when creating a link so users can consciously choose the desired behaviour.

@acelaya
Copy link
Member

acelaya commented May 2, 2020

Interesting. I never considered that, but it actually makes a lot of sense.

Thanks for the tip, this is really valuable information.

I will do some testing and experimentation, but if that approach works, I will definitely implement an option to configure what kind of redirection should be used.

Thanks again :-)

@Laurendus
Copy link
Author

Just to clarify: Are you planning on creating a global option or a option local to the link creation?

@acelaya
Copy link
Member

acelaya commented May 3, 2020

Probably both. You will be able to determine the default behavior, but also override it on a per-link basis if you want.

That's what I've done with other options, like the short code length.

However, it's very likely that I start with the global one, and then improve it later on.

@acelaya acelaya added this to the 2.3.0 milestone May 4, 2020
@acelaya
Copy link
Member

acelaya commented Jun 20, 2020

Hey @Laurendus.

This is now implemented and will be part of v2.3.0

@Laurendus
Copy link
Author

Very cool! I am looking forward to v2.3.0. And as always many thanks for your investment.

@acelaya
Copy link
Member

acelaya commented Aug 9, 2020

@Laurendus with vacation, the pandemic and such, it's taken v2.3.0 a bit more than usual to be released, but it is finally available.

It includes support for this. Feel free to open new issues if something doesn't work as expected.

@Laurendus
Copy link
Author

@acelaya Even without the pandemic totally understandable. I thank you again for your ongoing investment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants