If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Sheffield, UK
    Member #
    4 times

    I've just run Yslow on one of my sites and its telling me to set expires headers so that certain elements of the page get cached.

    I've had a quick search for how to do this but cant find a clear answer anywhere.

    Is this something I set in the meta tags at the top or is it attached to each relevant element or is it set in .htaccess?

    Can anyone explain how to do this?



  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Boston, MA
    Member #
    205 times
    The best way to auto-cache content on a php site is to use mod_expires (an Apache module), which you can set in your .htaccess file.

    If you do it in PHP, you want to do it at the HTTP header level on the specific page you're caching.

    For that, you'll do something like:
    PHP Code:
    60*60*24*14// 2 week cache
    header("Pragma: public");
    header("Cache-Control: maxage=".$expires);
    header('Expires: ' gmdate('D, d M Y H:i:s'time()+$expires) . ' GMT');
    Remember that you have to set your HTTP headers before outputting any other content, though, or you'll throw an exception.

    For more information, reference the PHP manual:

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 05:36 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: