What is the difference between 301, 302, 307 and 308 redirects?
IntermediateConceptHTTP, TLS & Certificates
Answer
301 and 308 are permanent; 302 and 307 are temporary. 307 and 308 preserve the request method and body, while historically 301 and 302 let clients switch POST to GET.
For SEO and caching, use 301/308 for permanent moves; for HTTP to HTTPS redirects 301 or 308 is standard, and 308 is safer for APIs.
More on HTTP, TLS & Certificates
What is the structure of an HTTP request and response?BeginnerWhich HTTP status code classes and codes should every DevOps engineer know?BeginnerWhat are the common HTTP methods and which are idempotent?BeginnerWhat changed between HTTP/1.1, HTTP/2 and HTTP/3?IntermediateHow does QUIC differ from TCP+TLS?AdvancedWhat are HTTP keep-alive and connection reuse, and why do they matter?Advanced