1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

In need of help with setting individual static expires headers

Discussion in 'Apache' started by Luke Corden, Nov 7, 2013.

  1. #1
    Hi forum,

    I have got a real headache going on about setting my expires headers.

    I've successfully done all the basic configuration is my .htaccess

    <IfModule mod_expires.c>
    
        ExpiresActive on
        ExpiresDefault "access plus 1 month"
    
      # CSS
        ExpiresByType text/css "access plus 1 year"
    
      # Data interchange
        ExpiresByType application/json "access plus 1 week”
        ExpiresByType application/xml "access plus 1 week”
        ExpiresByType text/xml "access plus 1 week”
    
      # Favicon (cannot be renamed!)
        ExpiresByType image/x-icon "access plus 1 year”
    
      # HTML components (HTCs)
        ExpiresByType text/x-component "access plus 1 month"
    
      # HTML
        ExpiresByType text/html "access plus 0 seconds"
    
      # JavaScript
        ExpiresByType application/javascript "access plus 1 year"
       
      # Manifest files
        ExpiresByType application/x-web-app-manifest+json "access plus 1 week”
        ExpiresByType text/cache-manifest "access plus 1 week”
    
      # Media
        ExpiresByType audio/ogg "access plus 1 year”
        ExpiresByType image/gif "access plus 1 month"
        ExpiresByType image/jpeg "access plus 1 month"
        ExpiresByType image/png "access plus 1 month"
        ExpiresByType video/mp4 "access plus 1 year"
        ExpiresByType video/ogg "access plus 1 year”
        ExpiresByType video/webm "access plus 1 year”
    
      # Web feeds
        ExpiresByType application/atom+xml "access plus 1 day”
        ExpiresByType application/rss+xml "access plus 1 day”
    
      # Web fonts
        ExpiresByType application/font-woff "access plus 1 month"
        ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
        ExpiresByType application/x-font-ttf "access plus 1 month"
        ExpiresByType font/opentype "access plus 1 month"
        ExpiresByType image/svg+xml "access plus 1 month"
    
    </IfModule>
    Code (markup):
    All of this is working lovely. But my problem now lies in a few instances where resources aren't being covered by this code. GTmetrix can list the individual resources but I have no idea how to manually change the expire time.

    I have spoken with dreamhost and they don't support
    mod_expires
    Code (markup):
    which seems strange. I just don't know where to go from here.

    From what I can tell I will need to go deeper into apache but I need to be given baby steps if this is the case. I am hoping your collective genius can guide me through.
    SEMrush
    Here are the following resources that need expires set:

    • http://fonts.googleapis.com/css?family=Ubuntu:400,700&subset=latin,latin-ext
    • https://apis.google.com/js/plusone.js
    • http://platform.twitter.com/widgets.js
    • http://p.twitter.com/f.gif?_=1383842094118&id=twitter-widget-0&lang=en&screen_name=aspirationalist&show_count=true&show_screen_name=false&size=m&twttr_variant=2.0&twttr_referrer=http%3A%2F%2Fwww.lukecorden.com%2F&twttr_widget=1&twttr_hask=0&twttr_li=0&twttr_pid=
    • https://twitter.com/i/jot?l=%7B%22_category_%22%3A%22tfw_client_event%22%2C%22language%22%3A%22en%22%2C%22client_version%22%3A%222.0%3Am%22%2C%22widget_origin%22%3A%22http%3A%2F%2Fwww.lukecorden.com%2F%22%2C%22format_version%22%3A1%2C%22dnt%22%3Afalse%2C%22triggered_on%22%3A1383842094217%2C%22event_namespace%22%3A%7B%22client%22%3A%22tfw%22%2C%22page%22%3A%22button%22%2C%22section%22%3A%22follow%22%2C%22action%22%3A%22impression%22%7D%7D
    • http://cdn.api.twitter.com/1/users/show.json?screen_name=aspirationalist&callback=twttr.setFollowersCount
    • https://oauth.googleusercontent.com/gadgets/js/core:rpc:shindig.random:shindig.sha1.js?c=2
    • https://ssl.gstatic.com/accounts/o/868078097-postmessagerelay.js
    Many, MANY, thanks in advance.
     
    Luke Corden, Nov 7, 2013 IP
    SEMrush
  2. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Hello,

    You can't optimize google and twitter.
    So, just disregard all the warnings related to the domains that you don't own.
     
    makeit easy, Nov 17, 2013 IP
  3. Luke Corden

    Luke Corden Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #3

    Thanks for the reply. So just to be clear. These all of warnings are related to a plugin for wordpress with the exception of one

    [http://fonts.googleapis.com/css?family=Ubuntu:400,700&subset=latin,latin-ext]

    which is related to the font used by my wordpress theme. Am I right in understanding that you are saying I cannot set expires for these elements?
     
    Luke Corden, Nov 17, 2013 IP
  4. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    You are welcome. Yes, you can't set expires for the domains that you don't have any control over their servers. You need to have an access to the server of fonts.googleapis.com to change its headers. You need to edit .htaccess file of fonts.googleapis.com. Can you do it? Most probably you can't.

    Also it's not related to a plugin on your server. There is nothing to be fixed for your side. Only the owners or employees of googleapis.com can change its headers.
    You can edit htaccess files of your own domains only.
     
    Last edited: Nov 17, 2013
    makeit easy, Nov 17, 2013 IP
  5. Luke Corden

    Luke Corden Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #5
    OK, well that is excellent news. You've saved me a big headache. I've been trying to get my google PageSpeed/yslow score up to 100%. I'm really close. Last night I recorded 98/99 respectively. But this is the one element that is holding me back at the moment. I'll have to try and find another workaround to squeeze a little extra juice out of my site

    I'm creating a series of tutorials for newbies and SEOs to follow so they can get an extra boost to their rankings by optimizing their sites this way and I'm also documenting my journey in the world of Internet Marketing to help others learn frm my mistakes. Feel free to stop by my blog and say hi. You can find me at http://www.lukecorden.com

    thanks very much for your help with this.

    LC
     
    Luke Corden, Nov 17, 2013 IP
  6. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Your site didn't load for me. I have to give a "zero" score for its page speed :)

    Only they can change those values. You can do nothing for external resources on your sites.
    As a solution, you can always remove their files from your sites if page speed is very important for you.

    In fact it's better to add less external resources to your sites. Because they will cause extra dns lookups even if they have proper expires headers. Also if their servers go down or if they stop hosting those files your pages might stop loading. If you have to use external resources, always try to add them to end of your html codes. So your pages may continue to load even if external resources don't load.
     
    makeit easy, Nov 18, 2013 IP
  7. Luke Corden

    Luke Corden Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #7
    Good advice. Not sure why the site didn't load though? Perhaps the DNS was still propagating from setting up CLoudFlare. It's all good now.
     
    Luke Corden, Nov 18, 2013 IP
  8. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #8
    I could load it through a proxy site. Nice site.
     
    Last edited: Nov 18, 2013
    makeit easy, Nov 18, 2013 IP
  9. Luke Corden

    Luke Corden Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #9
    thanks mate. i have reduced cloudflares security settings to the lowest settings you should be able to view it without the need for a proxy! That is very odd. Thanks for the heads up I will have to get a few people to check it out. That's not ideal eh!

    Glad you liked the site.

    And thanks again for the advice. Much appreciated.
     
    Luke Corden, Nov 18, 2013 IP
  10. Arturo Emilio

    Arturo Emilio Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #10
    Hi luke i checked your site and is really neat. However comparing the GtMetrix score it takes actually long time to load.
    check it out here if you may: http://gtmetrix.com/compare/fOr798WT/imNcLmFj
    My home page ( http://www.arturoemilio.es ) although almost double the size or yours it take 3 times less to load (3.75 against 1.62 although sometimes came down to 1.25) .
    Could you tell me if you are using a CDN? If so which one?
    Also, are you using any caching plugin? Which one?

    Hope to hear about. Regards!
     
    Arturo Emilio, Feb 25, 2014 IP
  11. Arturo Emilio

    Arturo Emilio Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #11
    Hi again, i've seen the report is missing. I can't edit the old one so here is a new comparison with luke's site.
    I may help you if i anyone let me know about how luke set up his site.
    http://gtmetrix.com/compare/imNcLmFj/zOnWfGQa
     
    Arturo Emilio, Apr 29, 2014 IP
  12. ashokdhan

    ashokdhan Well-Known Member

    Messages:
    270
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    160
    Digital Goods:
    2
    Articles:
    1
    #12
    ALL CODES TESTED GOOD TRY THESE IF YOU HAVE WORDPRESS SITE
    # BEGIN WPSuperCache
    # END WPSuperCache
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    
    # compress text, HTML, JavaScript, CSS, and 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
    
    # remove browser bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
    
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType 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 ##
    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]
    Code (markup):
     
    ashokdhan, Apr 17, 2015 IP