How to cache your static resources
Upcoming SlideShare
Loading in...5
×
 

How to cache your static resources

on

  • 462 views

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 ...

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

Statistics

Views

Total Views
462
Views on SlideShare
267
Embed Views
195

Actions

Likes
0
Downloads
1
Comments
0

5 Embeds 195

http://www.wesleysmits.com 153
http://plus.url.google.com 35
https://twitter.com 4
http://localhost 2
http://feeds.feedburner.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

How to cache your static resources How to cache your static resources Presentation Transcript

  • 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_headers module is installed and turned on in your apache server configuration. • Make sure your hosting company allows you to use a .htaccess file.
  • 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 (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"
  • 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.
  • Resources • What is caching? • Google: Optimize caching • Speed up your site with caching and cache-control • Convert Apache .htaccess to NGINX • Apache caching guide