Add expires headers

Discussion regarding Joomla! 3.x Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
fabioweb90
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Feb 09, 2016 11:02 am

Add expires headers

Postby fabioweb90 » Thu May 04, 2017 9:23 pm

Hello!
report in GTMetrix tell me this: There are 4 static components without a far-future expiration date.

I have this in htaccess but seems not working.. What can i do?

Code: Select all

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>


Thank you very much
You do not have the required permissions to view the files attached to this post.

SharkyKZ
Joomla! Guru
Joomla! Guru
Posts: 921
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Add expires headers

Postby SharkyKZ » Fri May 05, 2017 6:10 am

These resources are hosted remotely. Nothing you can do about it.

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 658
Joined: Wed Nov 18, 2009 3:53 pm

Re: Add expires headers

Postby the apprentice » Tue Jan 23, 2018 10:09 am

SharkyKZ wrote:These resources are hosted remotely. Nothing you can do about it.


So we need to ask our hosting providers if they can provide this expires headers to our scripts?

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4982
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: Add expires headers

Postby sozzled » Tue Jan 23, 2018 7:57 pm

@apprentice: are you asking a question about "4 static components without a far-future expiration date"? Please clarify your question relevant to your own situation.
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 658
Joined: Wed Nov 18, 2009 3:53 pm

Re: Add expires headers

Postby the apprentice » Wed Jan 24, 2018 7:06 am

On all those "analyse your website" websites, I get this alert "add expires headers to improve performance", and just wondered what's all that about, then I read here that it depends on the host.

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4982
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: Add expires headers

Postby sozzled » Wed Jan 24, 2018 7:11 am

This topic is 8 months old. This topic relates to a "problem" where the user had some external URLs. Do you have the same problem as the OP? If you have a similar problem, please describe in detail what are the symptoms of that problem. We may be better able to help you if we understand what you are referring to.
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 658
Joined: Wed Nov 18, 2009 3:53 pm

Re: Add expires headers

Postby the apprentice » Wed Jan 24, 2018 9:06 am

I added to this "Add expires headers" topic because I would like to add expires headers, if that's not too complicated.

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4982
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: Add expires headers

Postby sozzled » Wed Jan 24, 2018 9:20 am

Yes, but what's your problem or, put another way, what's your specific question and how does it tie into someone else's topic? Does your question relate to the first message posted in this topic and, if it does, how does it relate?

If you're simply asking a general question about adding expired headers then I think you've chosen an awkward way to ask it. This topic relates to one aspect of expired headers. Does this aspect of expired headers relate to you?
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 658
Joined: Wed Nov 18, 2009 3:53 pm

Re: Add expires headers

Postby the apprentice » Wed Jan 24, 2018 9:32 am

sozzled wrote:Does your question relate to the first message posted in this topic?


No, admittedly it relates to the thread title "Add expires headers" as that's what I would like to know, how to add expires headers. It does not relate to the first message.

SharkyKZ
Joomla! Guru
Joomla! Guru
Posts: 921
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Add expires headers

Postby SharkyKZ » Wed Jan 24, 2018 9:44 am

To add expires header, copy the code from first post to your .htaccess file.

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 658
Joined: Wed Nov 18, 2009 3:53 pm

Re: Add expires headers

Postby the apprentice » Wed Jan 24, 2018 10:06 am

Really? This code at the bottom of the .htaccess file and that's it? I will benefit in performance irrespective of hosting provider?

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 658
Joined: Wed Nov 18, 2009 3:53 pm

Re: Add expires headers

Postby the apprentice » Wed Jan 24, 2018 3:46 pm

Ok thanks, in the end (following this advice: https://www.gavick.com/blog/speed-websi ... ess-tricks) I added this:

<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.*
</ifModule>

and this:

# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers

JJazz
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 22, 2018 3:43 am

Re: Add expires headers

Postby JJazz » Tue Jan 30, 2018 4:50 am

Thanks for posting your final solution.

For greater clarity and ease of future maintenance you do not need to and probably should not express time units for long times in seconds.

From apache.org docs:

The plus keyword is optional. num should be an integer value [acceptable to atoi()], and type is one of:

years
months
weeks
days
hours
minutes
seconds


Return to “Performance - Joomla! 3.x”

Who is online

Users browsing this forum: No registered users and 6 guests