How Expires Headers works

By using Expires headers browser take decision to load resource from cache or directly from website server. For understanding how expires headers works :-

  1. Every time when website is loading on browser, browser check for expires headers for resources
  2. If expiry time set to the future then browser check for  cached version of resource at browser stored cache that it available or not.
  3. It will load resource from cache if available. Otherwise it will load direct from website server. If expire time is given past time then browser always fetch new version of resource.
How Expires Headers Works

For apache server which is widely used across the web world, Expires headers works on mod-expires module. By using this we can set expires headers for different type of resources. Basic syntax of expires headers as following:

ExpiresDefault "base [plus num type] [num type] ..."
ExpiresByType type/encoding "base [plus num type] [num type] ..."

Now here ExpiresDefault and ExpiresByType are directives  of modules. It helps to understand how expires headers will need to be added. For all default resources defined by server will have expires headers using ExpiresDefault directive.  For “ExpireByType type/encoding” will specified in syntax is used for adding expires headers and it will be remain limited to that particular type of encoding resources only. for example:- image/png , video/mp4, text/html

base  have three possible values on bases of what expiry time will be calculated. three values for base are as following

  • access :-  Expiry time for resource will calculated from first time access of resource.
  • now  :-  Expiry time for resource will  re- calculated from last time access of resource.
  • modification  :- Expiry time for resource will calculated from last time resource modified.

Expiry-time  is  deciding factor for any browser to use cached version of resource or fetch new from website server.  In syntax it shown using [plus num type] here plus is optional keyword. where is num is any integer value and type can be any following time/date data types:-

  • years
  • months
  • weeks
  • days
  • hours
  • minutes
  • seconds

so using this syntax we can make expires headers. For examples:-

ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresDefault "access plus 1 month"
ExpiresDefault "modification plus 4 weeks"

Notice: Undefined offset: 0 in /home/u779467576/domains/ on line 279

Notice: Trying to get property 'slug' of non-object in /home/u779467576/domains/ on line 279

Your email address will not be published. Required fields are marked *