Http response code of router automatic redirect 301 – how set 302 for development mode?

m.brecher
Generous Backer | 758
+
0
-

Hi,

Nette Router redirects automatically to canonical url with http response code 301. This is unsuitable in case of debugging routes, because browser cached the redirection. In developmen mode it is convenient if all redirects instead of 301 return 302. With 302 the browser does not any caching and route debugging is easy.

Exist a way how configure router that all automatic canonization redirects made by router will return http response code?

a) in production mode 301 – as Nette does default
b) in development mode 302

Notice: From documentation looks like such possibility exists not.

edit

In case there is no way how configure this, I recommend Nette internal developer team to implement above described feature as default function of Nette Router. 301 is really disturbing in case you have a trouble with some route collection (routing isnt easy for beginers) and you must after every testing clear browser cache by hand. 301 is only needed in production mode because of SEO. Search engine are on website always in production mode – there is absolutely no benefit from having 301 in development mode. This framework improving will help Nette beginners in route collection debugging. Everybody who starts design route collections has difficulties and redirection 301 makes learning of routing a hell :)

Thanks

Last edited by m.brecher (2023-01-10 02:45)

dkorpar
Member | 132
+
0
-

I usually just open DevTools and on the Network tab check the “Disable cache” and work like that when doing some testing…

m.brecher
Generous Backer | 758
+
0
-

@drkopar

I usually just open DevTools and on the Network tab check the “Disable cache”

Yes, good tip, or you may clean cache by hand. But for Nette beginners this 301 redirect caching would be TRICKY anyway. Moreover in conjunction with the not easy design of route collections this may create a real route-collection-design-hell. So having http response redirect code 302 in developer mode BY DEFAULT would be for BEGGINERS great feature.

I´m learning Nette route collections already two years but still spent yesterday ONE HOUR with one at the end very simple route collection and disturb the whole community with completely false comment about “router bug”. My comment in czech language is here:

https://forum.nette.org/…hyba-v-route

I have two boys, both of them using Nette for web application and they also have difficulties with full understanding the complexity of the router.