惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Schneier on Security
Cisco Talos Blog
Cisco Talos Blog
T
ThreatConnect
J
Java Code Geeks
博客园 - 司徒正美
A
Arctic Wolf
T
True Tiger Recordings
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
V
Vulnerabilities – Threatpost
Recorded Future
Recorded Future
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
The Register - Security
The Register - Security
S
Securelist
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
I
Intezer
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
K
Kaspersky official blog
博客园 - 聂微东
Last Week in AI
Last Week in AI
V
V2EX
小众软件
小众软件
F
Fox-IT International blog
Martin Fowler
Martin Fowler
Apple Machine Learning Research
Apple Machine Learning Research
T
Tenable Blog
F
Future of Privacy Forum
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
阮一峰的网络日志
阮一峰的网络日志
GbyAI
GbyAI
T
Threatpost
I
InfoQ
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
Tor Project blog
G
GRAHAM CLULEY
D
DataBreaches.Net

DEV Community

Building Strong Python Basics – Loops, Functions and Logic How to Choose the Right Tech Stack for Your Project I built a free multi-tab JSON editor — here's what I learned Building Cross-Platform Digital Products: Challenges and Best Practices Data Privacy in the Age of AI: How Product Teams Can Build Trust with Users What Would WordPress Look Like If It Were Designed Today? Why Backup Success Does Not Mean Database Recoverability Local AI Office Assistant That Never Sends Your Documents to the Cloud Building TaskForge: Translating Enterprise Chaos into an Open-Source Scheduler Tesla P40 in a Homelab: 24GB of Inference on a Budget Llama 4: Meta's Latest — Scout, Maverick, and the MoE Revolution George Hotz called AI code 'slop.' He's half right. Como Construir um Fluxo de Trabalho Baseado em Engenharia de Prompt e Automação We Audited Our Agent Tool-Call Traces. Half Our Eval Data Was Garbage. The Hidden Cost of Downtime: How SRE Error Budgets Protect National Economic Infrastructure Getting started with openHUMANS can be an exciting venture for developers looking to create innovative applications in the realm of human-ce Stack Overflow: A Powerful Community for Developers and Learners From Language Models to Humanoid Minds ✨ Road to Senior #2: How Computers Think in Numbers Why LLM debugging fails on fragmented repository context How to Deploy a LangGraph Agent on AWS Bedrock AgentCore An outreach kit for solo founders whose drafts can't hallucinate Open Satchel is live Amy Kwalwasser and the Growing Importance of Quantum Risk Modeling I Built ShellReq - A Native API Client for VS Code & Terminal If Microsoft and Uber can't afford AI coding, what chance do the rest of us have? MADCAP: Building a Multi-Agent Debate CLI That Argues With Itself So You Don't Have To Why most AI fails at IDOR (and how AMAS fixes it with causal reasoning) How to Audit a Laravel Codebase You've Inherited LangGraph 워크플로우 템플릿 (v34) BugBench: a developer origin story and practical guide for VS Code / Kiro users A solution to messy token systems for Next.js A NestJS reference app that proves the nest-native stack under realistic backend pressure Observability for AI Systems: Monitoring Drift, Hallucinations, and Reliability in Production I Thought “Data Analyst” Was the Whole Game… Then I Entered the Data Avengers Office 👀 Create and configure network security groups How to analyze the cost of Kafka? How I Shipped 2,500+ Commits With AI Agents Using a 12-Phase Workflow [Boost] We built MDCMS, a Markdown-first CMS for teams using AI agents Zero Heap Allocations at 1.18 GB/s: Deep Dive into ForgeZero 4.0.x The Minimum Viable Test Suite for Working with Agents Why Perplexity Started Citing My Blog: 5 Changes That Actually Worked Sync Supabase via OAuth: No Connection String Needed I asked three AI models the same API question. Only one had it right. Implementing Saga Pattern With Lambda Durable Function Why does AI forget what you said (and how to fix it) I built a daily Wordle-style game for AI tools - Here's how Mapping Polish company structures: querying KRS direct via API Built tmpdrop — a tiny self-hosted ephemeral file drop Running Local LLM - 0$ Personal Agentic AI Assistant - Part 3 LLD Object-Oriented Design: Interfaces & Abstract Classes (Designing Contracts) The Smaller Ship: Vitalik, the Ethereum Foundation's Restructuring, and What It Leaves for Investors Looking for 4 people to build something weird with me Building a Local-Only RAG System with Ollama and TypeScript The False Positive Tax: a 1:1 TP:FP analysis of eslint-plugin-security What's new in Data Preprocessor 1.5.x — R codegen, Robust Scaler, and a deadlock post-mortem How I self-hosted my Flask app on an old laptop for almost free I built a free DSA interview prep site because I was tired of the existing options I built an AI agent that migrates Next.js Pages Router to App Router Prisma Query Logging and PostgreSQL: Where the ORM Ends and the Database Begins Prisma query logging y PostgreSQL: dónde termina el ORM y empieza la base From Browser to Server : The Journey of an HTTP Request (Demystifying the Web’s Infrastructure) Santa Augmentcode Intent Ep.6 I Benchmarked 17 ESLint Security Plugins. Only One Found Every Vulnerability. How to Build a High-Performance Image Optimization Pipeline in 5 Minutes 50 Linux Commands Every DevOps Engineer Must Know Less Toil, More Flow - Automating the Path from Request to Implementation The Code Review Checklist I Actually Use How I run a small blog on Astro 5 + Content Collections Git: Best Practices for Professionals How IBM Bob Became My Everyday Coding Companion Solana Passkey Wallet: Replacing Seed Phrases with SIMD-0075 I built a small browser puzzle game about arrows I wrapped Claude Code in a zsh function. Here's every decision I almost got wrong. Mobile Game Optimization: A Unity Developer's Checklist Git: Best Practices for Beginners Three days I lost chasing a ghost that was already dead on disk Why Too Many Parts Hurt ClickHouse Performance Guardrails for Agent Output: Pluggable Validation Before and After LLM Calls Gemma Forge: Local AI Without the Setup Wall From Half‑dead Prototype to Local‑Only AI Medical Assistant: Rewiring MedClinic with GitHub Copilot Runninig a forkbomb in Jenkins What’s Actually Happening When You Use Git Preventing Recursive Tool Loops in LangChain Agents Building a Rock-Paper-Scissors CLI with TypeScript — Union Types, Conditionals, and Jest Your AI Coding Agent Wastes 80% of Its Context. Fixed That with Graph Theory. Why Flutter Has Become the Go-To Framework for Fintech App Development We built a scripting language just for AI agents. Here's why. Stop building AI inboxes. Build decision layers instead. Meme Monday Why I Built @editora/ui-react? Are AI tools the next level of abstraction in software development? Identity on Solana: Your Wallet Is Your Account One API Call Changed Everything The Internet Career Nobody Talks About Enough: What Is DevRel? Solar Panel Wiring Diagram: Series vs Parallel Hello everyone! Glad to join the dev.to community I Built an AI Agent That Tailors My Resume - Here's How Agents Actually Work I Built a WhatsApp OTP + AI Chatbot Platform for African Businesses
HTTP Headers Every Developer Should Know (2026)
Alex Chen · 2026-05-26 · via DEV Community

Alex Chen

HTTP Headers Every Developer Should Know (2026)

Headers are the hidden conversation between your browser and the server. Understanding them makes you a better developer.

The Request-Response Cycle

Browser → [Request Headers] → Server processes → [Response Headers] → Browser renders

Headers are key-value pairs.
They control caching, security, content type, authentication, and more.
Most work automatically — but when things break, headers are usually why.

Enter fullscreen mode Exit fullscreen mode

Request Headers (Client → Server)

Essential Headers

GET /api/users HTTP/1.1
Host: api.example.com          # REQUIRED. Domain of the server
User-Agent: Mozilla/5.0 ...    # Client software info
Accept: application/json       # What response formats I accept
Accept-Language: en-US         # Preferred language
Connection: keep-alive         # Reuse TCP connection

Enter fullscreen mode Exit fullscreen mode

Content Negotiation

# Tell the server what you want back
Accept: application/json        # JSON data
Accept: text/html               # HTML page
Accept: */*                     # Anything (default)
Accept: text/html,application/xhtml+xml;q=0.9,*/*;q=0.8  # With priorities!

# What encoding you accept
Accept-Encoding: gzip, deflate, br   # Compression preference

# What language
Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8

Enter fullscreen mode Exit fullscreen mode

Authentication

# Basic Auth (base64 encoded credentials)
Authorization: Basic dXNlcjpwYXNz  # "user:pass" base64-encoded

# Bearer Token (JWT / OAuth2)
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

# API Key (various patterns)
Authorization: ApiKey abc123def456
X-API-Key: abc123def456

Enter fullscreen mode Exit fullscreen mode

Conditional Requests (Caching!)

# "Only give me this if it changed since..."
If-None-Match: "33a64df5514310bf564"  # ETag value from last response
If-Modified-Since: Wed, 21 Oct 2026 07:28:00 GMT  # Last-Modified timestamp

# Server responds:
# → 200 OK + full data (if changed)
# → 304 Not Modified, no body (if NOT changed) ← SAVES BANDWIDTH!

Enter fullscreen mode Exit fullscreen mode

CORS Preflight

# Browser sends this before cross-origin requests:
OPTIONS /api/data HTTP/1.1
Origin: https://myapp.com
Access-Control-Request-Method: POST
Access-Control-Request-Headers: Content-Type, Authorization

# Server must respond with matching permissions:
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://myapp.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 86400           # Cache preflight for 24h

Enter fullscreen mode Exit fullscreen mode

Response Headers (Server → Client)

Status Codes & Basics

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 1234
Date: Tue, 26 May 2026 00:33:00 GMT
Server: nginx/1.24.0              # Hide or customize this in production!

Enter fullscreen mode Exit fullscreen mode

Common status codes you should know:

Code Meaning When to Use
200 OK Successful GET/PUT/PATCH
201 Created Successful POST (include Location header)
204 No Content Successful DELETE
301 Moved Permanently Permanent redirect
304 Not Modified Cached data still valid
400 Bad Request Invalid input
401 Unauthorized Not authenticated
403 Forbidden Authenticated but no permission
404 Not Found Resource doesn't exist
405 Method Not Allowed Wrong HTTP method for this endpoint
409 Conflict Resource state conflict (duplicate)
413 Payload Too Large Body exceeds size limit
415 Unsupported Media Type Wrong Content-Type
422 Unprocessable Entity Valid format but business rule failed
429 Too Many Requests Rate limited
500 Internal Server Error Something broke on server
502 Bad Gateway Upstream server error
503 Service Unavailable Server overloaded/maintenance

Caching Headers (Critical for Performance!)

# Version 1: Expiration-based
Cache-Control: public, max-age=3600      # Cache for 1 hour (CDN + browser)
Cache-Control: private, max-age=300     # Only browser cache (5 min), not CDN
Cache-Control: no-cache                  # Must revalidate with server each time
Cache-control: no-store                  # Never cache (API responses, auth pages)
Cache-Control: immutable, max-age=31536000 # Never revalidate (hashed assets)

# Version 2: Validation tags (used WITH no-cache)
ETag: "33a64df5514310bf564"             # Unique content hash/ID
Last-Modified: Wed, 21 Oct 2026 07:28:00 GMT  # Modification timestamp

# Practical examples:

# Static assets (CSS/JS/images) — AGGRESSIVE caching
Cache-Control: public, max-age=31536000, immutable
# Files with hash in name: main.a1b2c3d4.css → never changes

# HTML pages — SHORT cache, always validate
Cache-Control: public, max-age=0, must-revalidate
ETag: "abc123"

# API responses — NO cache by default
Cache-Control: no-store
# Unless it's a rarely-changing public API:
Cache-Control: public, max-age=60, stale-while-revalidate=300

Enter fullscreen mode Exit fullscreen mode

Security Headers

# Prevent clickjacking
X-Frame-Options: SAMEORIGIN
# Or: DENY (no framing at all)

# Prevent MIME sniffing
X-Content-Type-Options: nosniff

# XSS protection (legacy but still useful)
X-XSS-Protection: 1; mode=block

# Control referrer information
Referrer-Policy: strict-origin-when-cross-origin

# Permissions Policy (replaces Feature-Policy)
Permissions-Policy: camera=(), microphone=(), geolocation=()

# THE BIG ONE: Content Security Policy
Content-Security-Policy: 
  default-src 'self';
  script-src 'self' 'unsafe-inline' cdn.example.com;
  style-src 'self' 'unsafe-inline' fonts.googleapis.com;
  font-src 'self' fonts.gstatic.com;
  img-src 'self' data: https:;
  connect-src 'self' api.example.com wss://ws.example.com;
  frame-ancestors 'self';
  base-uri 'self';
  form-action 'self';

# Strict Transport Security (force HTTPS)
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
# Tells browser: "For the next year, only use HTTPS, never HTTP"

Enter fullscreen mode Exit fullscreen mode

CORS Response Headers

# For cross-origin API access:
Access-Control-Allow-Origin: https://myapp.com    # Specific origin (best!)
Access-Control-Allow-Origin: *                    # Public API (any origin)
Access-Control-Allow-Credentials: true            # Allow cookies/auth headers
Access-Control-Expose-Headers: X-Request-ID, X-RateLimit-Remaining
Access-Control-Max-Age: 86400                      # Preflight cache duration

Enter fullscreen mode Exit fullscreen mode

Rate Limiting Headers

# Tell clients their rate limit status:
X-RateLimit-Limit: 100            # Max requests per window
X-RateLimit-Remaining: 73         # How many left
X-RateLimit-Reset: 1716675800      # Unix timestamp when window resets
Retry-After: 60                   # Seconds until they can try again (for 429s)

Enter fullscreen mode Exit fullscreen mode

Debugging Header Issues

Using curl to Inspect Headers

# See all response headers
curl -I https://example.com/api/users

# See request AND response headers
curl -v https://example.com/api/users

# Custom headers
curl -H "Authorization: Bearer token123" \
  -H "Accept: application/json" \
  https://example.com/api/me

# Follow redirects and see each hop's headers
curl -vL https://example.com/redirect

# Check caching behavior
curl -I -H "If-None-Match: \"some-etag\"" \
  https://example.com/data
# Should return 304 if ETag matches!

Enter fullscreen mode Exit fullscreen mode

Browser DevTools

F12 → Network tab → Click any request → Headers section

Key areas to check:
1. General → Request URL, Method, Status Code
2. Request Headers → What your browser sent
3. Response Headers → What the server sent back
4. Preview/Parsed → Formatted response body

Pro tip: Right-click column headers → Manage Columns → Enable:
→ "Remote Address" (which server IP?)
→ "Time" (how long did it take?)
→ "Initiator" (what triggered this request?)

Enter fullscreen mode Exit fullscreen mode

Common Header Problems & Fixes

Problem: CORS error on frontend
Fix: Check Access-Control-Allow-Origin on server response
Note: Credentials mode requires specific origin, not *

Problem: Assets not updating after deploy
Fix: Check Cache-Control headers, add cache-busting query param or hash filename

Problem: 400 Bad Request on POST
Fix: Check Content-Type header matches what server expects (application/json)

Problem: Downloads showing as text in browser
Fix: Set Content-Disposition: attachment; filename="file.pdf"

Problem: API works in Postman but not browser
Fix: Usually CORS or missing Content-Type header. Check preflight OPTIONS response.

Problem: Images not loading from CDN
Fix: Check referrer policy or hotlink protection headers

Enter fullscreen mode Exit fullscreen mode

Quick Reference Card

Header Direction Purpose
Host Request Target server/domain
User-Agent Request Client identification
Accept Request Response format preference
Authorization Request Authentication credentials
Content-Type Both Format of request/response body
Content-Length Both Size of body in bytes
Cookie Request Send cookies to server
Set-Cookie Response Set cookies on client
Location Response Redirect URL (with 3xx status)
Cache-Control Both Caching directives
ETag Response Content version identifier
Last-Modified Response Last change timestamp
If-None-Match Request Conditional request (ETag)
If-Modified-Since Request Conditional request (timestamp)
X-Forwarded-For Request Original client IP (via proxy)
X-Request-ID Both Trace request through system

Which header has caused you the most debugging pain?

Follow @armorbreak for more practical web dev guides.