InMotion Hosting Support Center

When visiting a website, the website will cache in your browser. This cache can be controlled by configuring your Cache-Control HTTP headers for your website This is done by adding mod_expires in the .htaccess file of your server.

If you don't set your Cache-Control for the HTTP headers, then, you will have a longer wait times when visiting your website. Each time your website is accessed without Cache-Control, your website has to make a request to the server for each image, javascript file, CSS file, and so forth to load.

Browser caching is good because it allows your web resources to be stored in the browser for faster page load time. This makes your site faster to surf on the web. To remove the cache from your browser, your browser cache needs to be cleared. For information on clearing your browser cache, please see our article on How to clear your browser's cache. The following sections will explain the basics of setting up the Apache Module mod_expires in your .htaccess.

Basic code for setting expire dates for cache

In order to add browser caching to your website, you will need to set the date for when the cache expires. This cache code is placed in the .htaccess found in your public_html folder. You will need to edit your .htaccess file. Add the following code to the file and save it.

ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"

Now your site will set the time each for each resource that was added to the .htaccess to expire. In the previous code example, the jpg, jpeg, gif, png will expire in a year and pdf, javascript and flash files will expire in a month. More explanation o these settings will come later in this article. Next we will look at using the <ifmodule> for adding Cache-Control with mod_expires.

Code for mod_expires in an <ifmodule>

Using mod_expires in an <ifmodule> allows image types and other file types to be set in an array. This matches the file types to the specific expire time. This streamlines the htaccess code. In the code below, the file types are listed in a row like jpg|jpeg|png|gif|js|css|swf|ico|woff|mp3. Below is an example of the code to use.

<ifmodule mod_expires.c>
<Filesmatch "\.(jpg|jpeg|png|gif|js|css|swf|ico|woff|mp3)$">
    ExpiresActive on
    ExpiresDefault "access plus 2 days"

This sets the cache to expire to the same duration for each of the file types. To specify the specific times for each individual file type, you will want to use the previous code example. The following will explain the Directive types that are used for Cache-Control.

Directive types

There are three directive types; ExpiresActive, ExpiresByType, and ExpiresDefault. The following table explains the difference between them.

Caching directives
ExpiresActive Directive Enables the Expires headers for the website.
ExpiresByType Directive This defines the age of the cache header and the type of file to cache.
ExpiresDefault Directive This sets the age of the cache for all documents other than those specified in the ExpiresByType for the site.

Caching Directive bases

There are 3 base types the access, now, and modification type.

  • access
  • now (same as "access")
  • modification

Duration of cache time

The duration of cache time can be set to one of the following units of time.

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

Basic syntax for ExpiresByType intervals

The following shows the basic syntax for the ExpiresByType. Each file type can be set to specific times to expire the cache.

ExpiresByType text/html "access plus 2 days 12 hours"
ExpiresByType image/png "access plus 6 months 3 days"

Recommended Expire date ranges

You do not want to set your expire times for your cache to unrealistic settings. If you keep the cache to a maximum of a year and a minimum of a month, you should have your browser caching working optimized for your site.

  • Set your images to a long expire time like "access plus 1 year". Images take more time to load and are updated less frequently than other files.
  • Make your CSS, HTML, and Javascript expire at a minimum of a month like "access plus 1 month". CSS, HTML and JavaScript's typically are updated more when developing a site than the sites images.
  • Keep your cache expire date at most a year.

Support Center Login

Social Media Login

Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
2014-07-23 9:59 pm
I added the Basic expire code from this tutorial to my htaccess file and the GTMetrix Report is still saying "F" fail on that it must not be seeing it. Is the code changed to adding expire dates to the headers ? I do add this code to the htaccess file and that the only thing to do ? or is there another step ?
19,794 Points
2014-07-24 10:35 am
Hello PaulAlford,

Thank you for your question. We are happy to help, but will need some additional information. What is the exact issue and suggestion GTMetrix is giving you an "F" for?

It should begin as soon as you add the .htaccess rule. If you are using a CMS, such as Wordpress, Joomla, or Drupal, it's possible an existing rule in the .htaccess file is interfering with the rule you are adding.

If this is the case, you would instead go to the specific setting/plugin in the CMS, and set it there.

If you have any further questions, feel free to post them below.
Thank you,

n/a Points
2014-08-01 3:47 pm

What is it? Set-Cookie: PHPSESSID=kvtgebg048oc30mvuqnkeiviq2; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: max-age=604800, must-revalidate
Pragma: no-cache


Why the date Expires in past? The server answer with the included script of jcart on a site gives such answer lust date, having cleaned this script the server answer at once becomes true and Expires: shows date for a week forward. Any instructions in accesse, httpd don't give the decision. In the script there are no direct instructions Cache-control (no cache) on a caching ban. well or they are written by any hidden formulas? or it is meant that the POST method programmatically forbids a caching? In what area to look for? Thanks.

9,968 Points
2014-08-01 4:36 pm
Hello Mike, and thanks for your comment.

The Set-Cookie: PHPSESSID part is simply PHP setting a cookie for the session of a user.

I'm not sure why your Expires header would be showing a date in the past, what is the code you currently have in your .htaccess file for turning on expires headers? That is not normal behavior, so it seems like it's either something with your code or your server that is causing this.

- Jacob
n/a Points
2014-08-03 2:29 am

Hello JacoblMH! Thanks for the answer.In my .htaccess file  currently this:AddType application/x-httpd-php .php .htm .html

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^$ [NC]

RewriteRule ^(.*)$$1 [R=301,L]


RewriteRule ^news_([a-z_0-9]+).html$ news.html?id_news=$1 [L]

<IfModule mod_expires.c>

ExpiresActive On

ExpiresDefault "access 7 days"

ExpiresByType image/jpeg "access plus 7 day"

ExpiresByType image/jpg "access plus 7 day"

ExpiresByType image/png "access plus 6 months"

ExpiresByType image/gif "access plus 6 months"

ExpiresByType image/x-icon "access plus 6 months"

ExpiresByType application/javascript "access plus 6 months"

ExpiresByType text/css "access plus 6 months"

ExpiresByType text/javascript "access plus 6 months"

ExpiresByType text/js "access plus 6 months"


</IfModule>and in the file httpd.conf   contains this: 

RewriteEngine on

RewriteRule ^/(.*\.)v[0-9.]+\.(css|js|gif|png|jpg)$ /$1$2 [L,E=VERSIONED_FILE:1]

Header add "Cache-Control" "max-age=604800" env=VERSIONED_FILE

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|xml|txt|html|htm)$">

Header set Cache-Control "max-age=604800, public"



 I wrote above that on a site there is a script "jcart"

  and if absolutely to clean this script "jcart" then the answer of the server


   will be correct with the necessary date forward.ThanksMike

11,186 Points
2014-08-04 10:57 am
When viewing your headers, everything looks fine to me and I'm not seeing any dates in the past. It does appear that you may have some server side caching issues that you may want to speak with your server admin about. Unfortunately, I was unable to replicate the issue you are seeing at all.
n/a Points
2014-08-26 6:07 am


We are having excel files in docroot which will be often updated.

Whenever we updated the content of the .xls file we are not seeing the modifed content  while accesing through the URL. No script or program we are using. We just putting the file in docroot and access through the URL.

I feel like its caching somewhere may be in proxy.

I used mod_header to stop cacheing with below entry in httpd.conf file but still we are not getting the updated content, it takes time to get the updated content. COuld someone help me to fix it.

<FilesMatch "\.(xls)$">FileETag None#<ifModule mod_headers.c>Header unset ETagHeader set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"Header set Pragma "no-cache"Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"#</ifModule></FilesMatch>

31,565 Points
2014-08-26 9:06 am
Hello Abdur,
It sounds as if you simply do not want the xls files to cache. Try using the code below as it should set th xls files to a non caching state.

<FilesMatch "\.(xls)$">
ExpiresActive On
ExpiresDefault A1
Header append Cache-Control must-revalidate

Kindest Regards,
Scott M
n/a Points
2014-10-13 5:00 am

Hello scott,

 First of all thank you so much your suggestion as it really worked. Now only one problem remainsSorry to reply laste as i was struck ip some other work.

As you suggested i enabled the below in httpd.conf file.

<FilesMatch "\.(xls)$">ExpiresActive OnExpiresDefault A1Header append Cache-Control must-revalidate</FilesMatch>

I am telling you here what exactly happening.I last modifed a file name sample.xls on August monthI first accessed the file today before enabling the expire module.It gave me the proper file as this is the first time i am accessing. Then i modifed the file again today then accessed for 2nd time but it didnt show me the modified content because proxy serves the file from cache.From the above steps i replicated the issue, Then i enabled the expire and header module.After that i accessed the file again but i was getting the same old file even though i enabled the option.

I then tried accessing one more file which was ceated on august month first time after enabling the expire. [Difference between above and this one is , In the above case i accessed the file one time before activitating exipre module, but here in this case i accessed the file only after enabling]As usual it give the proper content. Then i modifed again and accessed, this time it worked, I can able to see the modified content.

With the above 2 testing i got the below conclusion.If we access an old last modified file for the first time, Heuristic expiration policies set a expire time by deafult.After that whatever i access how many time i accessed eventough modifying the file, it will always shows the old file from cache.Enabling the expire module also wont work till the expire time set by the Heuristic expiration policies expires. After it expired, a new exipre time wont be set by Heuristic expiration policies as we enabled the expire module.If no expire module enabled then again a new expire date is set by the Heuristic expiration policies.

In the 2nd testing, i didnt access the file before enabling the expire module hence there was no expire time set because of that its working fine eventhough many times we do modifying.

Your suggestion gave me solution for my current issue, Thank you so much for that.But i want to know how to solve the same for the old files also. because its a website where everyone access the file and all the files already accessed by the users. So we cannot go by the 2nd testing result like creating a new fileWe have to make this work for old files also.hence could you please tell us what we can do to serve the files not from the cache eventhough already expiration date set by Heuristic expiration policies.

To simplify my question This expire configuration works for the file which is not accessed and cached before in proxyWhat configuration we can do for the file which is already accesed and cached in the proxy and having a expiration date .

31,565 Points
2014-10-13 12:50 pm
Hello Rasheed,

Browsers should behave the same in this, but they may each act a bit differently. The way it should work, is browsers who have already cached the files will wait until the expiration date set in the headers before checking back. Each user can clear their own cache, but adding the exception for the specific file types will not cause those that have cached already to remove their cached versions.

Kindest Regards,
Scott M
n/a Points
2014-10-14 12:02 am

<p>Hello Scott,</p><p>So in my case the only soultion is we have to wait till the expire date which is there in the header to expire. After it expired only this expire configuration will work. Am i right ?</p><p>Eventhough clearing the cache in browser wont help ?</p><p>Because i cleared the cache and tested but its not working.</p><p>Please kindly help me in my understanding.</p>

11,186 Points
2014-10-14 8:45 am
Be sure to fully clear all temporary data in your browser. If any references to those files are left over, it will still attempt to deliver the old files.
n/a Points
2014-10-15 1:28 am

I deleted all the temporary files still i am getting the old files if the same file was accessed once before enabling the expire module.

If i havent access the file before enabling the expire module then everything works fine.

Additional information,In my case proxy server is serving the file from the cache

28,417 Points
2014-10-15 10:14 am
Hello Rasheed,

Sorry to hear that you're still having problems with the caching. If you're using a proxy server that has cached the files, there's nothing we can clear browser-side. You will need to have the proxy server files cleared. You will also need to check and see if the proxy server will abide by the expiration rules set by the website. Otherwise, the proxy server caching will need to be cleared on a regular basis.

Arnel C.
n/a Points
2014-10-15 10:59 pm

Hello Arnel,

The configuration which is given by Scott is working. only thing is its not working for the file which is already cached once in the proxy earlier. If i wait till the already defined expiration date expired then after that everything works normal and the modification are relfecting as soon as we change from server end.

I understood that if the file cached in proxy then we need to clear from prxy end.

After client accepted to enable this Expire configuration i'll enalbe in the server and will ask the network team to clear the cache for this specific webserver from their end then everything will start works fine I hope.

Thank you all for helping me in resolving this issue. :)



n/a Points
2014-10-03 12:40 pm


I implemented following mod_expires in our httpd.conf file and run into some issue. 

LoadModule expires_module modules/   --> Enabled mod_expires load module on httpd.conf file and added following.

<IfModule mod_expires.c>

 ExpiresActive on

<FilesMatch "\.(gif|jpe?g|ico|png|css|js)$">

  ExpiresDefault "access plus 2 weeks"


<FilesMatch "\.(docx?|pff|pdf|xlsx?|zip|tar|gz)$">

  ExpiresDefault "access plus 1 month"



While testing, I noticed the jpg files that are published on NAS are being cached properly, example: Internet/FSE_MEDIA/stelprdb5359300.jpg but the files that are on theme directory (application ear file) are not being cached. FSE_WIDTheme/themes/html/FSE_WIDTheme/images/headercorner.gif

could someone assist on this. Thank You

- Prasana 

19,794 Points
2014-10-03 1:05 pm
Hello Prasana,

Thank you for your question. We are happy to help, but it is difficult to troubleshoot since there can be many causes.

I recommend reviewing your error logs (such as apache error logs) to narrow down the cause, since it can be anything stopping the theme directory from caching.

If you have any further questions, feel free to post them below.

Thank you,
n/a Points
2014-10-13 11:34 pm

Hi John,

Thanks for your response. I was busy with prouction issues and was not able to respond you at the earliest.

Regarding the theme files (that are Theme ear file) that are not being cached, I reviewed the apache error log and do not notice anything. I need your inputs on below:

1) Do you think we need to some cache configuration settings on theme customization(as my applicaiton runs on portal).  

2) We have external caching (Akamai caching), is't something that blocking my code for mod_expires (ExpireDefault directive type) that I listed earlier.

Please let me know your thoughts.



11,186 Points
2014-10-14 8:41 am
With an external caching server as you are describing, a user would be accessing that server when they access your site in which caching data may not be passed on to the user. To allow browser caching, you would need need to configure this on the external caching server.
n/a Points
2014-10-26 10:53 am

Thanks! This article is so helpful to me because I was having a problem with Wordpress caches, after following this article (of course did some modification with the expiry time) and the problem solved!

The direct article to my problem wasn't helpful at all, this solution should be suggested there too!

n/a Points
2014-12-19 2:16 pm


The GTmetrix report for my sites -- newly hosted on InMotion -- lists files which are not covered by the W3 total Cache WP plugin: all are links to outside servers (Facebook, ShareThis, couter, etc.)  Yet, all of these are static, never-changing.

How do I set these to have long expiration?  



28,417 Points
2014-12-20 8:40 am
Hello Josefus,

Thanks for the question. W3TC Caching plugin tries to set the expiry headers for files on a web page so that they don't have to be loaded repeatedly. This allows the viewer to see the webpage faster since the file is "cached" and they don't have to load a new copy of it. If those links are static and don't change, then you most likely don't have to worry about it. Also, it is possible that you're running into files on servers where the expiry header aren't supported. So, unfortunately, you won't be able to affect those files with the expiry header. I was looking around the WordPress Codex and found this discussion about Expiry Headers in W3TC. I hope this helps to explain the issue!

Please let us know if you have any further questions or comments.

Arnel C.
n/a Points
2014-12-20 10:57 am

Thank you, Amel!Yes, I understand what W3TC does, and it has been very effective (my page loading dropped from about 700ms to 220ms after switching from another caching plugin), but my YSlow score still points to areas that need improvement.

In addition, InMotion Systems staff is telling me that my sites experience Resource Overage... and wanted me to lower my GTmetrix scores, and this is why I'm here with questions.Specifically, under Add Expires Headers (YSlow score: E-56), it says that the following links -- all static, all going to outside servers -- do not have expiration:

Add Expires headersThere are 4 static components without a far-future expiration date.

I believe that W3TC doesn't have any effect on these outside links...  So, I'm asking whether there are instructions (code) that I can place in the .htaccess file that will have an effect on links going to outside servers.Recently, InMotion staff was able to help me refine my .htaccess file on some other issues, I'm hoping that if you cannot do the same here you would inquire among your colleagues and come up with the code that can do this. Once I have the code structure, I can enter it very easily.

Thank you again!



19,794 Points
2014-12-20 12:43 pm
Hello JF,

Thank you for contacting us. I spent some time researching this (and asking around the office) as was not able to find a good working solution.

The problem is that when you pull something from an external server/source, you are affected by their server performance and load time.

It may be possible to pull the resources periodically and store them on your server, but it is almost like a reverse cdn setup, and can cause other problems.

A better solution may be to host the scripts/resources you are pulling externally on the same server your website resides on. Then you have control over the files, and caching, etc.

Thank you,
n/a Points
2014-12-20 1:30 pm

Thank you, JohnPaul!

On your suggestion to  host those scripts/resources locally... if you take a close look at the specific items I included in my query, they come from StatCounter, googleAnalytics and ShareThis -- I don't believe you can relocate any of them. And, as you said, reverse CDN might introduce other problems.

I gather there might not be a good solution to this one... but if you find one at a later time, I'd love to hear about it.

Thanks again,


n/a Points
2015-03-30 3:31 am

I have been tryint to enable Expire headers from my .htaccess, but it is not enabled, I have been add several types of code for expire header. it is not working, Please let me know what i'am in wrong in that

28,417 Points
2015-03-30 7:53 am
Hello Kumar,

Sorry for the problem with the expire headers. In order for us to help you we would need to see your .htaccess entries. If you can please provide account information or the .htaccess entries, then we can proceed with troubleshooting the problem.

If you have any further questions or comments, please let us know.

Arnel C.
n/a Points
2015-04-22 3:24 pm

I am a newbie, and trying to build my own site.  I have GT metrix saying: There are 6 static components without a far-future expiration date.  Here are those: 

Here is a copy of my htacess:

# Redirect old file path to new file pathRedirect /hatsan-reman/ ----------------------------------------------------------------------# CORS-enabled images (@crossorigin)# ----------------------------------------------------------------------# Send CORS headers if browsers request them; enabled by default for images.#<IfModule mod_setenvif.c>  <IfModule mod_headers.c>    # mod_headers, y u no match by Content-Type?!    <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">      SetEnvIf Origin ":" IS_CORS      Header set Access-Control-Allow-Origin "*" env=IS_CORS    </FilesMatch>  </IfModule></IfModule># ----------------------------------------------------------------------# Webfont access# ----------------------------------------------------------------------# Allow access from all domains for webfonts.# Alternatively you could only whitelist your# subdomains like "".<IfModule mod_headers.c>  <FilesMatch "\.(ttf|ttc|otf|eot|woff?|woff2?|font.css|css)$">    Header set Access-Control-Allow-Origin "*"  </FilesMatch></IfModule>## EXPIRES CACHING ##<IfModule mod_expires.c>ExpiresActive OnExpiresByType image/jpg "access 1 year"ExpiresByType image/jpeg "access 1 year"ExpiresByType image/gif "access 1 year"ExpiresByType image/png "access 1 year"ExpiresByType text/css "access 1 month"ExpiresByType text/html "access 1 month"ExpiresByType application/pdf "access 1 month"ExpiresByType text/x-javascript "access 1 month"ExpiresByType application/x-shockwave-flash "access 1 month"ExpiresByType image/x-icon "access 1 year"ExpiresDefault "access 1 month"</IfModule>## EXPIRES CACHING ####  VARY: ACCEPT-ENCODING HEADER ##<IfModule mod_headers.c>  <FilesMatch "\.(js|css|xml|gz)$">    Header append Vary: Accept-Encoding  </FilesMatch></IfModule>##  VARY: ACCEPT-ENCODING HEADER ### BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress

What did I screw up?  Thank you!!!!

28,417 Points
2015-04-23 8:45 am
Hello Scott,

If those static components are NOT going to change because they're graphics (generally tiny graphics, too) or consistent files, then you should not have to worry about putting an expiration date on them. The Gtmetrix page is for determining how best to optimize your site for speed purposes. In this case, it really won't make that much of a difference. You can also contact GTMetrix directly for advice if you wish to continue pursuing this particular issue. We're not sure why they mark those particular items with any large concern for the purpose of the site opimization.

Arnel C.
n/a Points
2015-04-23 8:50 am

OK so my htacess is correct and proper?  No changes needed or reccomended?  Thank you for your help I will follow up as you suggest.

n/a Points
2015-07-01 7:24 am



I have gtMetrix report with regarding below issue:


I have set .htaccess file as per above detail but i didn't get any result. I have clear cache also.


Any suggestion for this?



28,417 Points
2015-07-01 11:24 am
Hello Digant,

The only way you're going to get rid of the files you're listing is to NOT make reference or use of those files FROM your website. Gtmetrix is taking a profile of your site by seeing EVERY element that is loading or requries time to load on an internet browser. Your website may contain multiple references to files/fonts/links, etc. that may not even be on your website - but since they require time to load, they will count as a negative in terms of the performance of your website.

You can't change the properties of those offsite files, except in how you reference them. If you really want to get them off of gtmetrix report, then remove the dependencies from your website.

I hope this helps to answer your question, please let us know if you require any further assistance.

Arnel C.

n/a Points
2015-09-09 8:34 pm

Hello Dear All, we are having a wordpress site and we have the following .htaccess file code. We are getting Add Expires headers score F (0). Can anyone please let us know how to fix this problem. ? We also tried W3 PlugIn but having the same result. Thank you. 

.htaccess file is as here.

# BEGIN WordPress

Header set Connection keep-alive

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]



# compress text, html, javascript, css, xml:

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript


# END WordPress

<IfModule mod_expires.c>


    ExpiresActive on

    ExpiresDefault                                      "access plus 1 month"


  # CSS


    ExpiresByType text/css                              "access plus 1 year"





  # Data interchange


    ExpiresByType application/atom+xml                  "access plus 1 hour"

    ExpiresByType application/rdf+xml                   "access plus 1 hour"

    ExpiresByType application/rss+xml                   "access plus 1 hour"


    ExpiresByType application/json                      "access plus 0 seconds"

    ExpiresByType application/ld+json                   "access plus 0 seconds"

    ExpiresByType application/schema+json               "access plus 0 seconds"

    ExpiresByType application/vnd.geo+json              "access plus 0 seconds"

    ExpiresByType application/xml                       "access plus 0 seconds"

    ExpiresByType text/xml                              "access plus 0 seconds"



  # Favicon (cannot be renamed!) and cursor images


    ExpiresByType image/              "access plus 1 week"

    ExpiresByType image/x-icon                          "access plus 1 week"


  # HTML


    ExpiresByType text/html                             "access plus 0 seconds"



  # JavaScript


    ExpiresByType application/javascript "access plus 1 year"

    ExpiresByType application/x-javascript "access plus 1 year"

    ExpiresByType text/javascript "access plus 1 year"

    ExpiresByType text/css "access plus 1 month"

    ExpiresByType application/pdf "access plus 1 month"

    ExpiresByType text/x-javascript "access plus 1 month"

    ExpiresByType application/x-shockwave-flash "access plus 1 month"

    ExpiresByType image/x-icon "access plus 1 year"



  # Manifest files


    ExpiresByType application/manifest+json             "access plus 1 week"

    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"

    ExpiresByType text/cache-manifest                   "access plus 0 seconds"



  # Media files


    ExpiresByType audio/ogg                             "access plus 1 month"

    ExpiresByType image/bmp                             "access plus 1 month"

    ExpiresByType image/gif                             "access plus 1 month"

    ExpiresByType image/jpeg                            "access plus 1 month"

    ExpiresByType image/png                             "access plus 1 month"

    ExpiresByType image/svg+xml                         "access plus 1 month"

    ExpiresByType image/webp                            "access plus 1 month"

    ExpiresByType video/mp4                             "access plus 1 month"

    ExpiresByType video/ogg                             "access plus 1 month"

    ExpiresByType video/webm                            "access plus 1 month"





<ifModule mod_gzip.c>

mod_gzip_on Yes

mod_gzip_dechunk Yes

mod_gzip_item_include file .(html?|txt|css|js|php|pl)$

mod_gzip_item_include handler ^cgi-script$

mod_gzip_item_include mime ^text/.*

mod_gzip_item_include mime ^application/x-javascript.*

mod_gzip_item_exclude mime ^image/.*

mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*


AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript


Header unset ETag

FileETag none


28,417 Points
2015-09-09 9:28 pm
Hello Alam,

Sorry to hear you're having problems with the headers. I'm not sure how you have your WordPress installation is configured (caching, etc.). You may want to review this post in the support forum. They discuss the same problem and have possible solutions for you.

I hope that helps to answer your question! If you require further assistance, please let us know!

Arnel C.
n/a Points
2015-11-12 2:59 pm


I note two things about the recommended htaccess lines.

1) Expires for html files are not set.

HTML5 Boilerplate recommends ExpiresByType text/html  "access plus 0 seconds" This seems like a good strategy to me to set a very low cache time for html files, allowing the super fresh html to pull in any resources with changed file names. Although 0 seconds may be more for development than production.

Should text/html be added to the code recommendations in this article?

2) Expires "Basic code" is not wrapped in <ifmodule>

I assume mod_expires.c is on by default on InMotion servers, so a check is not needed if users aren't using Filesmatch.

Is that correct? Is it better practice to wrap Expires lines in ifmodule just in case, or not wrap to avoid tasking the server with the check?



19,794 Points
2015-11-13 11:37 am
Hello Chris,

Thank you for contacting us. The section above on "Basic syntax for ExpiresByType intervals" includes HTML. As described above "Make your CSS, HTML, and Javascript expire at a minimum of a month like "access plus 1 month". CSS, HTML and JavaScript's typically are updated more when developing a site than the sites images."

These are the recommendations as written by the author at that time. Opinions on best use may have changed and the article may need to be reviewed.

Yes, mod_expires is on by default on our servers. It is difficult to provide "best practice" tips, since the preferred settings can differ, based on your specific site setup and needs. If you want to test, there is a section above that includes the "Code for mod_expires in an ."

If you have any further questions, feel free to post them below.

Thank you,

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

38 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!