• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Apache for Newbie: Set up Apache with mod_expires

December 17, 2023

Apache for Newbie: Set up Apache with mod_expires

When it comes to web hosting, Apache is one of the most popular and widely used web servers. It is known for its flexibility, reliability, and extensive features. One such feature is mod_expires, which allows you to set expiration dates for different types of files on your website. In this article, we will guide you through the process of setting up Apache with mod_expires to optimize your website’s performance and improve user experience.

What is mod_expires?

Mod_expires is an Apache module that enables you to control the caching of files on your website. By setting expiration dates for different file types, you can instruct the user’s browser to cache these files locally. This reduces the number of requests made to the server, resulting in faster page load times and reduced bandwidth usage.

Enabling mod_expires

To enable mod_expires, you need to have administrative access to your server. If you are using a VPS hosting service like Server.HK, you can easily enable mod_expires by following these steps:

  1. Connect to your server via SSH or any other preferred method.
  2. Open the Apache configuration file using a text editor. The location of this file may vary depending on your server setup, but it is commonly found at /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf.
  3. Search for the line that starts with LoadModule expires_module modules/mod_expires.so. If it is commented out (starts with a ‘#’), remove the ‘#’ to uncomment the line.
  4. Save the changes and exit the text editor.
  5. Restart Apache for the changes to take effect. You can do this by running the command sudo service apache2 restart or sudo systemctl restart apache2 depending on your server’s operating system.

Configuring mod_expires

Once mod_expires is enabled, you can start configuring it to set expiration dates for different file types. The configuration is done in the Apache configuration file as well. Here’s an example of how you can configure mod_expires:


<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html "access plus 1 day"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType text/css "access plus 1 week"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
</IfModule>

In the above example, we have set different expiration dates for HTML files, JPEG images, CSS files, JavaScript files, and PNG images. You can customize these values according to your specific needs. The format for setting expiration dates is "access plus [time period]", where the time period can be specified in minutes, hours, days, weeks, months, or years.

Summary

Setting up Apache with mod_expires is a simple yet effective way to optimize your website’s performance. By leveraging browser caching, you can reduce server load, improve page load times, and enhance user experience. With the help of a reliable VPS hosting provider like Server.HK, you can easily enable and configure mod_expires to take full advantage of this powerful Apache module.

For more information about Hong Kong VPS hosting, visit https://server.hk.

Recent Posts

  • How to Set Up a Mail Server on Hong Kong VPS: Postfix, Dovecot, and Email Deliverability (2026)
  • How to Run a SaaS Product on Hong Kong VPS: Architecture and Deployment Guide 2026
  • Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026)
  • Cryptocurrency and USDT Payment for VPS Hosting: Why It Matters for Global Businesses (2026)
  • How to Speed Up Your Website for China: A Technical Optimization Guide 2026

Recent Comments

  1. Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026) - Server.HK on How to Monitor Your Hong Kong VPS: Uptime, Performance, and Alert Setup Guide (2026)
  2. Best Hong Kong VPS Providers in 2026: Compared by Speed, Routing, and Value - Server.HK on How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  3. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  4. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  5. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot