Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 28th Mar 2011, 10:28 AM   #1
Warrior Member
 
Join Date: 2011
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default
How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

I heard that specifying expiration for image and css files is a good practice. But I do not understand this. I would like to know how to specify this?

Adi

adianadiadi is offline  
Unread 29th Mar 2011, 08:28 PM   #2
HyperActive Warrior
 
Join Date: 2010
Posts: 160
Thanks: 11
Thanked 12 Times in 12 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

You can do this in your htaccess file ....

# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000

A2592000 means 1 month in the future (60*60*24*30=2592000)
Cash Money Hosting is offline  
The Following User Says Thank You to Cash Money Hosting For This Useful Post:
Unread 31st Mar 2011, 12:08 PM   #3
Warrior Member
 
Join Date: 2011
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Originally Posted by Cash Money Hosting View Post

You can do this in your htaccess file ....

# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000

A2592000 means 1 month in the future (60*60*24*30=2592000)
Thank you very much sir. May I know what is the benefit of doing so?

adianadiadi is offline  
Unread 31st Mar 2011, 12:28 PM   #4
Active Warrior
 
Join Date: 2011
Posts: 48
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

use expire active on command
jargonbust is offline  
Unread 1st Apr 2011, 12:43 PM   #5
Warrior Member
 
Join Date: 2011
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Originally Posted by Cash Money Hosting View Post

You can do this in your htaccess file ....

# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000

A2592000 means 1 month in the future (60*60*24*30=2592000)
When I added this to my htaccess file, I encountered:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

So what is wrong with my file?

adianadiadi is offline  
Unread 2nd Apr 2011, 10:46 PM   #6
copy and paste geek
War Room Member
 
Join Date: 2005
Location: Calgary
Posts: 1,571
Thanks: 149
Thanked 321 Times in 259 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Originally Posted by adianadiadi View Post

So what is wrong with my file?
Just a guess, but from your post it sounded like you loaded his whole post into the .htaccess file. You should only add this part.

Code:
# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000
And related to another question you asked, the benefit of doing this is that if you change something on your site, visitors will see the new version sooner. A browser often caches style sheets or pages. It will sometimes show the older version until the visitor forces a refresh or the time set in the htaccess above runs out.

Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

The KimW WSO
Lloyd Buchinski is offline  
Unread 3rd Apr 2011, 06:13 AM   #7
Warrior Member
 
Join Date: 2011
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Originally Posted by Lloyd Buchinski View Post

Just a guess, but from your post it sounded like you loaded his whole post into the .htaccess file. You should only add this part.

Code:
# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000
No. I have added only the above part. I found even adding the first line "ExpiresActive On" makes my site start giving error messages.

adianadiadi is offline  
Unread 3rd Apr 2011, 07:58 AM   #8
HyperActive Warrior
 
Join Date: 2010
Posts: 160
Thanks: 11
Thanked 12 Times in 12 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Your webhost probably does not have the module mod expires set.

Cash Money Hosting is offline  
Unread 4th Apr 2011, 03:53 AM   #9
Warrior Member
 
Join Date: 2011
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Originally Posted by Cash Money Hosting View Post

Your webhost probably does not have the module mod expires set.
My site is hosted with the help of godaddy. What can I do to know the exact problem? How can I set this mod expires module?

Adi

adianadiadi is offline  
Unread 23rd Jul 2012, 03:09 AM   #10
DigiMix Marketing Design
 
DigiMixus's Avatar
 
Join Date: 2012
Location: New York City
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

My site's hosted with GoDaddy too. I'm going to try out the code and see how it works. Thanks for sharing!

@michaelsalafia
Wordpress Web Design
Strategist / Designer / Growth Hacker @ DigiMix NYC
DigiMixus is offline  
Unread 23rd Jul 2012, 03:29 AM   #11
DigiMix Marketing Design
 
DigiMixus's Avatar
 
Join Date: 2012
Location: New York City
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

I added expire image code to my .htaccess file then ran a Google Page Speed Test and it immediately increased my page speed from 83/100 to 85/100. But it's registering that I am not setting some of the .jpg's to expire.

@michaelsalafia
Wordpress Web Design
Strategist / Designer / Growth Hacker @ DigiMix NYC
DigiMixus is offline  
Unread 8th Jun 2016, 12:47 AM   #12
FrontEnd WebDev, Designer
 
Join Date: 2016
Location: United States
Posts: 45
Thanks: 3
Thanked 6 Times in 6 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

Hi my friend i believe you want to speedup your website dont you

well adding expiry of different files on your.htaccess file is the one thing only..... if you test your website from gtmetrix or https://developers.google.com/speed/pagespeed/insights/ you will see there are tons of minifications and customization required with your website CSS, Js files, images, CDN connectivity and many more.... well here's the one solution that i have for you

go with WP Rocket plugin and try any Cloud hosting ones you will see the brilliant difference of speed on your website.
AllenMack is offline  
Unread 25th Jun 2016, 11:52 PM   #13
Active Warrior
 
Join Date: 2016
Posts: 34
Thanks: 1
Thanked 4 Times in 4 Posts
Default
Re: How do I specify expiration for my css & image files?
Share on: 
fb share twitter share gplus share more share

I have never actually thought about expiraton of files haha, i am glad that I stumbled on this topic. I will make sure that I try this.
ITDaniel is offline  
Closed Thread


Bookmarks

Tags
css, expiration, files, image


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 09:07 PM.