Back to Learning Center
SaaS Security

HTTPS Best Practices Every Developer Should Know in 2026

9 min read·Updated May 2026·By CertNotify Team

Having an SSL certificate is necessary but not sufficient. A large number of websites have HTTPS enabled but implement it incorrectly — leaving users exposed to downgrade attacks, mixed content vulnerabilities, and misconfigured security headers. This guide covers everything you need to implement HTTPS properly.

1. Redirect All HTTP Traffic to HTTPS

Every HTTP request should be permanently redirected (301) to its HTTPS equivalent. This must be done server-side, not just in your application code.

# nginx — redirect all HTTP to HTTPS
server {
  listen 80;
  server_name example.com www.example.com;
  return 301 https://$host$request_uri;
}
# Apache — .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Important — avoid redirect chains like HTTP → HTTP/www → HTTPS. Each extra redirect adds latency and can cause issues with certain clients. The optimal path is a single 301 from HTTP to HTTPS.

2. Implement HTTP Strict Transport Security (HSTS)

HSTS tells browsers that your site should only ever be accessed over HTTPS. Once a browser receives this header, it will automatically upgrade HTTP requests to HTTPS and refuse to connect if the certificate is invalid — without any user-visible HTTP request.

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

Start with a short max-age (e.g., 300 seconds) to test, then increase to 31536000 (1 year). Submit your domain to the HSTS preload list so browsers know to use HTTPS even on the very first visit.

3. Fix Mixed Content Issues

Mixed content occurs when an HTTPS page loads resources (images, scripts, stylesheets, fonts, iframes) over HTTP. Modern browsers either block mixed content entirely or display a warning, degrading user experience and triggering browser security warnings.

Find mixed content using:

  • Browser DevTools → Console (look for "Mixed Content" warnings)
  • Chrome DevTools → Security tab
  • Content-Security-Policy with upgrade-insecure-requests directive
# Add to your CSP to auto-upgrade HTTP resources
Content-Security-Policy: upgrade-insecure-requests

4. Essential Security Headers

These HTTP response headers are independent of SSL/TLS but critical to a complete HTTPS implementation:

HeaderExampleWhat It Does
Strict-Transport-Securitymax-age=31536000; includeSubDomains; preloadForces browsers to only use HTTPS for your domain for the specified duration. Include preload to join the HSTS preload list.
Content-Security-Policydefault-src 'self'; script-src 'self' 'nonce-{random}'Prevents XSS and data injection attacks by declaring which sources of content are allowed to load on your page.
X-Frame-OptionsDENYPrevents your site from being embedded in iframes on other origins — protects against clickjacking attacks.
X-Content-Type-OptionsnosniffPrevents browsers from MIME-type sniffing the response — ensures content is interpreted as declared.
Referrer-Policystrict-origin-when-cross-originControls how much referrer information is sent with requests — limits data leakage to third parties.
Permissions-Policycamera=(), microphone=(), geolocation=()Restricts which browser features your site can access — formerly called Feature-Policy.

5. Enable OCSP Stapling

When a browser connects to your site, it needs to verify that your certificate has not been revoked. Without OCSP stapling, the browser makes a separate HTTP request to the CA's OCSP responder — adding latency and a privacy concern (the CA learns which sites you visit).

With OCSP stapling, your server periodically fetches a signed OCSP response from the CA and includes it in the TLS handshake. The browser receives the revocation status without making a separate request — faster and more private.

6. Keep Certificates and Configurations Current

Use certificates from trusted CAs with at least 2048-bit RSA keys or P-256 ECDSA
Prefer ECDSA certificates for better performance and equivalent security
Monitor certificate expiry and configuration drift with an external monitoring service
Keep your TLS library (OpenSSL, BoringSSL, etc.) updated — TLS vulnerabilities are patched regularly
Test your HTTPS configuration regularly with SSL Labs or CertNotify

Use our free Security Headers Checker to verify the headers side of your HTTPS configuration — HSTS, CSP and more — graded A+ to F with specific fix recommendations. It reads response headers only; cipher suites need a handshake scanner such as SSL Labs.

Common questions

What are the most important HTTPS best practices for production?

Enable HSTS with at least 1-year max-age and includeSubDomains. Use TLS 1.2 and 1.3 only (disable 1.0 and 1.1). Configure strong cipher suites (prefer ECDHE key exchange, AES-GCM). 301-redirect all HTTP to HTTPS. Renew certificates at least 30 days before expiry. Enable OCSP stapling to reduce certificate validation latency.

What is OCSP stapling and why does it matter?

OCSP stapling lets the server periodically fetch its own revocation status from the CA and include it in the TLS handshake. Without stapling, browsers contact the CA directly on every page load — adding 50-200ms of latency and a privacy risk. With stapling, this lookup is eliminated for the visitor. Enable with ssl_stapling on; in nginx.

Which cipher suites should I disable?

Disable: RC4 (broken), 3DES/SWEET32, export-grade cipher suites, MD5 and SHA-1 signatures, and anonymous cipher suites (aNULL). Keep: ECDHE with AES-128/256-GCM, CHACHA20-POLY1305, and TLS 1.3 cipher suites. Use Mozilla's SSL Configuration Generator (ssl-config.mozilla.org) for a server-specific recommended configuration.

How do I check if my HTTPS configuration meets current standards?

Use a security headers checker to verify response headers, and a full handshake scanner to audit cipher suites and protocol versions. Run the domain through SSL Labs' free server test at ssllabs.com/ssltest — it grades from A+ to F and shows specific weaknesses. Aim for A+ by enabling HSTS and disabling weak protocols.

References and further reading

The specifications and primary documentation this article is based on.

Read next

More guides on the same subject.

Check Your Security Headers

Use our free Security Headers checker to scan your domain for missing or misconfigured HTTP security headers.

Check Security Headers