How to cache static resources
What is caching?
”Caching (pronounced “cashing”) is the process
of storing data in a cache”
What is a cache then?
”A cache is a temporary storage area.”
Why should I cache static resources?
•

The website loads faster for the users

•

The server doesn't have to be bothered by any
unnecessary traffic.
How to start caching
This tutorial is only for XAMPP server installations
•

Make sure the mod_expires module is installed and
turned on in your apache server configuration.

•

Make sure the mod_h...
The .htaccess code
The lines starting with an # are comments meant to
explain the code written directly below it.
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0

!

# Set up caching on media files for 1 year (f...
Recommendations
•

Use expires instead of Cache-control: max-age
(expires is more widely supported)

•

Set expires to a m...
Resources
•

What is caching?

•

Google: Optimize caching

•

Speed up your site with caching and cache-control

•

Conve...
Upcoming SlideShare
Loading in …5
×

How to cache your static resources

726 views
661 views

Published on

A simple and short presentation explaining what caching is, why you should start caching your static resources (CSS, Javascript and image files for example) and shows the code which enables caching in your users browsers.

Note: This tutorial is only for XAMPP server installations

Published in: Self Improvement, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
726
On SlideShare
0
From Embeds
0
Number of Embeds
362
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How to cache your static resources

  1. 1. How to cache static resources
  2. 2. What is caching?
  3. 3. ”Caching (pronounced “cashing”) is the process of storing data in a cache”
  4. 4. What is a cache then?
  5. 5. ”A cache is a temporary storage area.”
  6. 6. Why should I cache static resources?
  7. 7. • The website loads faster for the users • The server doesn't have to be bothered by any unnecessary traffic.
  8. 8. How to start caching This tutorial is only for XAMPP server installations
  9. 9. • Make sure the mod_expires module is installed and turned on in your apache server configuration. • Make sure the mod_headers module is installed and turned on in your apache server configuration. • Make sure your hosting company allows you to use a .htaccess file.
  10. 10. The .htaccess code The lines starting with an # are comments meant to explain the code written directly below it.
  11. 11. # Turn on Expires and set default to 0 ExpiresActive On ExpiresDefault A0 ! # Set up caching on media files for 1 year (forever?) ! ExpiresDefault A29030400 Header append Cache-Control "public" ! # Set up caching on media files for 1 week ! ExpiresDefault A604800 Header append Cache-Control "public" ! # Set up 2 Hour caching on commonly updated files ! ExpiresDefault A7200 Header append Cache-Control "proxy-revalidate" ! # Force no caching for dynamic files ! ExpiresActive Off Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" Header set Pragma "no-cache"
  12. 12. Recommendations • Use expires instead of Cache-control: max-age (expires is more widely supported) • Set expires to a minimum of one month for static resources. • Don't set expires more than one year into the future.(It violates the RFC guidelines). • Set last-modified to the last date the resource was changed.
  13. 13. Resources • What is caching? • Google: Optimize caching • Speed up your site with caching and cache-control • Convert Apache .htaccess to NGINX • Apache caching guide

×