본문으로 건너뛰기
🛠️ToolsShed

HTTP Cache Header Generator

Cache-Control 헤더를 시각적으로 구축하고 지시사항을 설명합니다.

생성된 헤더

Cache-Control: (none)

사전 설정

이 도구 소개

Cache-Control 헤더는 HTTP 캐싱의 기본 요소로, 브라우저, CDN, 프록시가 콘텐츠를 저장하고 재사용하는 방식을 제어합니다. 올바르게 설정하는 것은 웹 성능에 필수적입니다. 잘못 설정하면 오래된 콘텐츠가 사용자에게 제공되거나 캐시 미스로 인한 불필요한 서버 부하가 발생할 수 있습니다. 그러나 구문이 복잡하고, 여러 지시어와 그들의 상호작용은 경험 많은 개발자도 혼동하기 쉽습니다.

이 도구는 Cache-Control 헤더의 비주얼 빌더를 제공하여 개별 지시어를 토글하고 생성된 헤더를 실시간으로 확인할 수 있습니다. `public, max-age=3600, s-maxage=7200, stale-while-revalidate=86400`과 같은 구문을 외우는 대신 직관적인 인터페이스를 통해 옵션을 선택하고 최종 헤더를 HTTP 응답에 직접 복사할 수 있습니다. 정적 자산, API 끝점, HTML 페이지, CDN 캐시 콘텐츠 등 일반적인 시나리오용 사전 설정 템플릿이 추측 없이 구성을 빠르게 시작하도록 도와줍니다.

웹 개발자, DevOps 엔지니어, 백엔드 전문가는 캐시 문제 디버깅, CDN 캐싱 정책 설정, 다양한 지시어의 상호작용 학습에 이 도구가 매우 유용할 것입니다. 생성된 헤더는 서버 응답(Express.js, FastAPI, Java, Go 등)에 직접 복사할 수 있어 수동 입력 오류를 제거하고 캐싱 전략 구현을 가속화합니다.

자주 묻는 질문

코드 구현

from flask import Flask, make_response, send_file
import hashlib
import time

app = Flask(__name__)

@app.route('/static/asset')
def serve_immutable_asset():
    """Cache forever — content-hashed file (e.g., bundle.abc123.js)"""
    response = make_response("asset content")
    response.headers['Cache-Control'] = 'public, max-age=31536000, immutable'
    return response

@app.route('/api/data')
def serve_api_data():
    """Short-lived private API response with ETag"""
    data = "dynamic content"
    etag = hashlib.md5(data.encode()).hexdigest()

    response = make_response(data)
    response.headers['Cache-Control'] = 'private, max-age=60'
    response.headers['ETag'] = f'"{etag}"'
    return response

@app.route('/page')
def serve_page():
    """HTML page: always check freshness, cache 10 minutes"""
    response = make_response("<html>...</html>")
    response.headers['Cache-Control'] = 'public, max-age=600, must-revalidate'
    response.headers['Last-Modified'] = 'Mon, 01 Jan 2024 00:00:00 GMT'
    return response

@app.route('/auth')
def serve_auth_page():
    """Never cache sensitive pages"""
    response = make_response("sensitive content")
    response.headers['Cache-Control'] = 'no-store'
    return response

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.