Skip to content
Tutorial emka
Menu
  • Home
  • Debian Linux
  • Ubuntu Linux
  • Red Hat Linux
Menu

Cara Tuning mod_expires pada Apache demi Server Cache yang Efisien

Posted on January 31, 2024

 

Modul mod_expires pada Apache digunakan untuk mengontrol pengaturan header Expires HTTP dan direktif max-age pada header Cache-Control dalam respons server. Header-header ini menentukan seberapa lama klien (browser atau proxy) akan menyimpan sumber daya dalam cache. Mengoptimalkan pengaturan ini dapat secara signifikan mengurangi beban server dan meningkatkan pengalaman pengguna dengan mengurangi waktu pemuatan.

Berikut adalah bagian mod_expires yang dioptimalkan untuk server produksi, mencakup berbagai jenis file:

## EXPIRES CACHING ##
<ifmodule mod_expires.c="">
    ExpiresActive On

    # Default expiration: 1 hour after request
    ExpiresDefault "now plus 1 hour"

    # HTML components
    ExpiresByType text/html "access plus 0 seconds"

    # Data interchange
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType application/rss+xml "access plus 1 hour"
    ExpiresByType application/atom+xml "access plus 1 hour"

    # Favicon (can be cached for a long time)
    ExpiresByType image/x-icon "access plus 1 year"

    # Media: images, video, audio
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"

    # CSS and JavaScript
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType application/x-javascript "access plus 1 year"
    ExpiresByType text/javascript "access plus 1 year"

    # Webfonts
    ExpiresByType font/otf "access plus 1 month"
    ExpiresByType font/ttf "access plus 1 month"
    ExpiresByType font/woff "access plus 1 month"
    ExpiresByType font/woff2 "access plus 1 month"
    ExpiresByType application/font-woff "access plus 1 month"
    ExpiresByType application/font-woff2 "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"

    # Other
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
</ifmodule>

Penjelasan Pengaturan

  • ExpiresDefault: Waktu penyimpanan default untuk sumber daya yang tidak cocok dengan aturan lain. Diatur menjadi 1 jam, tetapi dapat disesuaikan berdasarkan seberapa sering konten Anda berubah.
  • HTML dan Data Interchange: Jenis konten ini biasanya sering berubah dan diatur untuk kedaluwarsa segera (0 detik) atau setelah periode singkat (1 jam untuk feed).
  • Favicons: Jarang berubah dan dapat disimpan dalam cache untuk periode yang lebih lama (1 tahun).
  • Media Files: Gambar, video, dan audio biasanya tidak diperbarui dengan frekuensi tinggi. Diatur untuk kedaluwarsa dalam 1 bulan, tetapi dapat ditingkatkan jika sumber daya ini jarang berubah.
  • CSS dan JavaScript: Karena file-file ini mungkin berubah dengan pembaruan situs web, tetapi tidak sefrekuensi konten HTML, mereka diatur untuk periode cache yang lebih lama (1 tahun). Pastikan versi file ini diatur untuk menghindari masalah cache saat diperbarui.
  • Webfonts: Font umumnya tidak berubah setelah diatur, jadi periode cache yang lebih lama (1 bulan) adalah sesuai.
  • Tipe Lainnya: Untuk sumber daya seperti PDF dan jenis gambar tertentu, sesuaikan waktu penyimpanan berdasarkan seberapa sering sumber daya ini diperbarui.

Catatan Tambahan

Sesuaikan pengaturan ini berdasarkan frekuensi pembaruan konten spesifik Anda.

Pastikan Anda memiliki strategi versioning untuk aset seperti CSS dan JavaScript untuk mencegah masalah cache ketika file-file ini diperbarui.

Ingatlah bahwa caching yang agresif mungkin menyebabkan masalah ketika konten diperbarui di server tetapi masih di-cache di browser klien.

Monitor secara teratur dan sesuaikan pengaturan ini berdasarkan kebutuhan spesifik dan umpan balik dari lingkungan produksi.

Recent Posts

  •  How to Fix ‘docs.google.com Refused to Connect’ Error in Windows 10/11
  • Aerynos Feb 2026 Update: Faster Desktops and Moss Performance Boost
  • Pangolin 1.16 Adds SSH Auth Daemon: What You Need to Know
  •  How to Fix Windows Audio Endpoint Builder Service Not Starting Errors
  • What’s New in elementary OS 8.1.1 with Linux Kernel 6.17?
  • Microsoft Tests AI Feature to Monitor Open Apps on Windows 11 Taskbar
  • Is Google Chrome Secretly Downloading AI Models? Everything You Need to Know
  • Shotcut 2.6.2 Fixes Timeline & HEVC Crashes: What You Need to Know
  • Hyprland Desktop 0.54 Released: Adds Per-Workspace Layouts
  • What’s New in Grafana 12.4: Dynamic Dashboards and Enhanced Observability
  • What are the Microsoft Outlook Steam Account Ads? Here is a Breakdown of the Policy Violation
  • Open Source Endowment Launches to Support FLOSS Infrastructure
  • What is Microsoft Teams Wi-Fi Tracking? This is the Privacy Issue You Should Know
  • Windows Server Finally Supports Boot REFs After 14 Years
  • LXD 6.7 Released: Powerful Container and VM Manager Upgrades
  • Ubuntu 26.04 LTS Snapshot 4 Release Notes and Download Guide
  • What’s New in Calibre 9.4? A Deep Dive into the Latest E-Book Progress Tracking Features
  •  How to Fix Clipchamp No Internet Connection Error on Windows
  • Why Are Sudo Password Asterisks Missing in Ubuntu 26.04?
  • Omarchy Linux 3.4 Released: Arch-Based OS with New Features Explained
  • OnlyOffice Docs 9.3 Adds Multipage View and PDF Signatures
  • LibreOffice 26.2.1 Released with 70+ Bug Fixes and Improvements
  • fwupd 2.0.20 Released: Simplified Firmware Updates for Linux Users
  • What is GStreamer 1.28.1? A Deep Dive into the Latest Stability and Security Update
  • Typhoon Weather App Gets Qt6 Upgrade: What’s New?
  • Inilah Cara Mengenali Aplikasi Bodong Penghasil Uang Agar Kalian Nggak Jadi Korban Penipuan Digital
  • Apa itu Error Kode LADK3 saat Buka Rekening Brimo? Dan Solusinya!
  • BOHONG??? Inilah Rincian Anggaran Makan Bergizi Gratis, Ternyata Uang Bahan Makanannya Nggak Sampai Rp15.000!
  • Inilah Tugas Proktor Ujian TKA SD/SMP 2026, Baca Dulu Ada Yang Beda!
  • Tips Pajak Coretax: Inilah Cara Memastikan Lembaga Amil Zakat yang Sah Agar Pajak Kalian Berkurang!
  • Prompt AI Menyusun Script Pola Suara Karakter agar Brand Jadi Ikonik
  • Prompt AI untuk Merancang Karakter Brand yang Ikonik
  • Prompt AI Audit Konten Sesuai Karakter Brand
  • Prompt AI Merubah Postingan LinkedIn Jadi Ladang Diskusi dengan ChatGPT
  • Prompt AI: Paksa Algoritma LinkedIn Promosikan Konten Kalian
  • Apa itu Spear-Phishing via npm? Ini Pengertian dan Cara Kerjanya yang Makin Licin
  • Apa Itu Predator Spyware? Ini Pengertian dan Kontroversi Penghapusan Sanksinya
  • Mengenal Apa itu TONESHELL: Backdoor Berbahaya dari Kelompok Mustang Panda
  • Siapa itu Kelompok Hacker Silver Fox?
  • Apa itu CVE-2025-52691 SmarterMail? Celah Keamanan Paling Berbahaya Tahun 2025
©2026 Tutorial emka | Design: Newspaperly WordPress Theme