michael,
@michael@thms.uk avatar

I’ve worked in web development for what feels like a century. I must’ve written a bazillion redirects in Apache, nginx, php, node, and probably half a dozen other languages/configurations.

And still, to this day, I need to Google ‘302 vs 301’ every single time I write a redirect to remind myself which one is the permanent and which one is the temporary.

If someone has a tip to help me remember, I’ll be forever grateful!

negative12dollarbill,
@negative12dollarbill@techhub.social avatar

@michael
If it's a 301,
It's moved and the story is done
If it's a 302,
It's moved but its comeback is due

michael,
@michael@thms.uk avatar

@negative12dollarbill this is my favourite. Thank you. Let’s see if I’ll still remember it next time.

negative12dollarbill,
@negative12dollarbill@techhub.social avatar

@michael
I would also refer you to my more famous poem about rsync:

If there's a slash on the end of the source,
It means “only copy the contents” of course
But if the source has no slash on the end
The folder itself is what you will send

michael,
@michael@thms.uk avatar

@negative12dollarbill funnily enough that is something that I’ve never had a problem with. It just seems logical to me 😁

aslakr,
@aslakr@mastodon.social avatar

@michael I thought one should use 307 and 308 since 301/302 might change protocol (eg. from POST to GET). But if the redirect is only for GET this might not be a problem. https://www.rfc-editor.org/rfc/rfc9110.html#name-307-temporary-redirect

michael,
@michael@thms.uk avatar

@aslakr technically yes. Practically I don’t think I’ve ever seen these in production 🤷‍♂️

aslakr,
@aslakr@mastodon.social avatar

@michael The fact that Apache's "permanent" and "temp" in https://httpd.apache.org/docs/trunk/mod/mod_alias.html#redirect and https://httpd.apache.org/docs/trunk/rewrite/flags.html#flag_r generates 301 and 302 says a lot

michael,
@michael@thms.uk avatar

@aslakr I suspect the main reason for the very limited adoption of 303, 307, and 308 is that 99.9% of of redirects should be GET requests.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • webdev
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines