I see in LinkController.php that it appears that redirects are hard-coded to be 301 redirects. This means that browsers should cache the redirect after they hit it for the first time. However, there are cases when a 302 redirect is preferred, such as when you plan to frequently update the destination of the short link, or when you want to collect analytics every time someone visits the short link, rather than only the first time.
Expected Behavior
The redirect type (301 or 302) should be configurable.
Current Behavior
It is hard-coded at 301.
Possible Solution
There should be a new configuration option in .env to set the redirect type.
Alternatively, this could be a per-link option. However, I think it is simpler to make the global default be configurable.
I see in LinkController.php that it appears that redirects are hard-coded to be 301 redirects. This means that browsers should cache the redirect after they hit it for the first time. However, there are cases when a 302 redirect is preferred, such as when you plan to frequently update the destination of the short link, or when you want to collect analytics every time someone visits the short link, rather than only the first time.
Expected Behavior
The redirect type (301 or 302) should be configurable.
Current Behavior
It is hard-coded at 301.
Possible Solution
There should be a new configuration option in
.env
to set the redirect type.Alternatively, this could be a per-link option. However, I think it is simpler to make the global default be configurable.