The Apache Haus Forum

Advanced search  

News:

Welcome to Apache Haus Distribution Forum

Pages: [1]   Go Down

Author Topic: Speed Up Sites with htaccess Caching  (Read 5113 times)

mario

  • Administrator
  • Member Elite
  • *****
  • Offline Offline
  • Posts: 579
Speed Up Sites with htaccess Caching
« on: January 06, 2009, 05:40:39 PM »

This article shows 2 awesome ways to implement caching on your website using Apache .htaccess (httpd.conf) files on the Apache Web Server. Both methods are extremely simple to set up and will dramatically speed up your site

Apache .htaccess caching code
Code: [Select]
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>

For fail-safe code implement this to the above
Code: [Select]
<IfModule mod_expires.c>
# any Expires Directives go here
</IfModule>
 
<IfModule mod_headers.c>
# any Header directives go here
</IfModule>

At least one of the 2 modules needs to be built into Apache; although they are included in the distribution, they are not turned on by default. To find out if the modules are enabled in your server, find the httpd binary and run httpd -l; this should print a list of the available modules. The modules we
Logged

rabinalvin

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
  • CODING EXPERT
Re: Speed Up Sites with htaccess Caching
« Reply #1 on: November 26, 2017, 05:27:42 PM »

It's ignore java scripts ans CSS, yes or not.
Logged

mario

  • Administrator
  • Member Elite
  • *****
  • Offline Offline
  • Posts: 579
Re: Speed Up Sites with htaccess Caching
« Reply #2 on: November 27, 2017, 06:12:01 PM »

You see js and css file in the two days line ;)
Logged
Pages: [1]   Go Up
 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13