Orofold Labs

Launching soon

Notes Get in touch

Operations and security 4 min read Updated

HTTPS and certificates: renewal, HSTS and mixed content

In short

Automate renewal well before expiry, send HSTS only over HTTPS with a deliberate max-age, and serve every resource over HTTPS.

A certificate that expires silently takes a site offline for every visitor at once, and browsers then warn people away. Keeping HTTPS running therefore means renewing automatically, not from memory. Short certificate lifetimes change that job.

Why lifetimes are short

Let’s Encrypt issues certificates with a default lifetime of 90 days. It also offers optional short-lived certificates with a lifetime of 6 days. Short lifetimes limit how long a stolen certificate stays useful, but they turn manual renewal into a recurring task, so renewal has to be automated. Let’s Encrypt describes automation as essential for ease of use and reliability.

Renew automatically, and before the deadline

Let’s Encrypt recommends an ACME client that renews automatically. Its integration guide describes habits worth copying:

  • check renewal information at least twice a day, and renew when the server recommends it;
  • as a backstop, renew when a third of the lifetime is left, which means about 30 days before expiry for a 90-day certificate;
  • retry failures with exponential backoff, at most once per day per certificate;
  • run scheduled jobs at a randomised second of the day;
  • treat a failed renewal as a warning rather than a fatal error, and send the errors to the person responsible.

If you manage more than 10,000 hostnames, renew them in small batches, which limits the impact of an outage or a local failure.

Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea

Turn on HSTS in steps

HTTP Strict Transport Security tells browsers to use HTTPS for a host and to refuse to bypass certificate errors on later visits. The MDN reference describes the header and its parts:

PartEffectNote
max-ageHow long, in seconds, the browser remembers the policyEach response resets the timer; a value of 0 switches HSTS off
includeSubDomainsApplies the policy to all subdomainsEach subdomain should send its own header
preloadAsks for the domain to be included in a list built into browsersRequires a max-age of at least 31,536,000 and includeSubDomains

Browsers ignore the header when it arrives over HTTP. A browser learns the policy only after one secure visit, so the very first request can still be exposed to a network attacker. Preloading closes that gap, but MDN notes that the preload list is run by Google and is not part of the HSTS specification. Start with a short max-age, check the whole site, and raise the value only when every subdomain is ready.

Insecure requests should receive a permanent redirect, such as a 301, to the HTTPS address. That redirect must not carry the HSTS header. The differences between redirect codes are covered in redirects: 301, 302, 307, 308, and a full list of headers is in HTTP security headers worth setting.

Serve every resource over HTTPS

Mixed content appears when an HTTPS page loads an insecure resource. MDN separates two kinds. Upgradable content, such as images, audio and video, is loaded over HTTPS automatically. Blockable content, such as scripts, stylesheets, frames, and requests made with fetch or XMLHttpRequest, is blocked. Requests to an IP address instead of a domain name are blocked even when they could otherwise be upgraded.

The fix is simple to state: serve all content over HTTPS, use relative or HTTPS references in templates, and use HTTPS versions of third-party resources. MDN also mentions the Content Security Policy directive upgrade-insecure-requests as a related option. Rules about where content may load from belong in a Content Security Policy that holds. Test in the browser console, because a page can look correct while a blocked script has quietly stopped working.

Checklist before the next renewal

  1. Confirm that the ACME client renews automatically and that its schedule runs at a randomised time.
  2. Check the expiry date of each certificate and the date of the last successful renewal.
  3. Set an alert for failed renewals, and name the person who receives it.
  4. Redirect every HTTP request to HTTPS with a permanent redirect, and do not send the HSTS header on that response.
  5. Walk through the pages in the browser console and look for mixed-content warnings.
  6. Raise the HSTS max-age only after every subdomain serves HTTPS correctly.

The rollout order and the checklist are general engineering practice. The figures and rules come from the sources listed for this article.

Sources and limits

Common questions

How long is a Let’s Encrypt certificate valid?
The default lifetime is 90 days, and short-lived certificates with a 6-day lifetime are optional. Renewal should happen well before expiry, not on the last day.
Should HSTS be switched on at once?
Not as a first step. HSTS takes effect only after a secure visit, and preloading is a separate step, so raise max-age gradually once every subdomain serves HTTPS.
Why can a page served over HTTPS still break?
Mixed content can block scripts, stylesheets and frames that load over HTTP, even when the main page uses HTTPS. The browser console shows which requests were blocked.

Sources

  1. Certificate Lifetime Rationale and Plans, Let’s Encrypt. Accessed 24 November 2026
  2. Integration Guide, Let’s Encrypt. Accessed 24 November 2026
  3. Strict-Transport-Security header, MDN Web Docs (Mozilla). Accessed 24 November 2026
  4. Mixed content, MDN Web Docs (Mozilla). Accessed 24 November 2026

Further reading

Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea

All notes