Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    Best Caching Method?

    I've been reviewing caching methods with .htaccess on Apache, and I'm a little confused. Some tutorials use mod_headers, while some use mod_expires, while some use both. Are any of them better than the other? And is this the same as caching by HTTP headers?

  • #2
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Those two mods have different purposes, but both can achieve the same result.

    http://httpd.apache.org/docs/2.0/mod/mod_headers.html
    http://httpd.apache.org/docs/2.0/mod/mod_expires.html

    I like the simplicity of mod_expires:
    Code:
    ExpiresDefault "access plus 30 days"
    But with mod_headers, you have greater control over what http headers are sent.


    These two mods control the headers that browsers look at for client side caching.
    If you want server side caching, look into memcache
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • Users who have thanked eak for this post:

    Joseph Witchard (06-11-2009)

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Is this the same as using http headers? Same syntax and everything?

  • #4
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Is what the same as using http headers?
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #5
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by eak View Post
    Is what the same as using http headers?
    mod_headers and mod_expires.

  • #6
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Yes, both of those mods will edit/append http headers when Apache sends a document.
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • Users who have thanked eak for this post:

    Joseph Witchard (06-13-2009)

  • #7
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    All right. Since they have "mod" in their names, am I right in assuming that they're considered part of Apache Mod_Rewrite?

  • #8
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    No, they are not associated with that module.
    Many Apache modules use that naming convention to indicate that it is a module.
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • Users who have thanked eak for this post:

    Joseph Witchard (06-15-2009)

  • #9
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Ah, okay.

    Is there really a need for server-side caching if I do it on the client side? Also, is there a certain mime type for PHP files?
    Last edited by Joseph Witchard; 06-15-2009 at 11:24 PM.

  • #10
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Yes, server side caching has its benefits, especially for large sites.
    For example, you can use memcache to store your query results in memory.
    There are also modules for caching PHP opcode (APC for instance).
    I read somewhere that an opcode cache will be included in PHP6.


    I think the php mimetype is application/x-httpd-php. What do you need that for?
    I have never need that since I primarily use php to send text/html or application/xhtml+xml.
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • Users who have thanked eak for this post:

    Joseph Witchard (06-17-2009)

  • #11
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by eak View Post
    Yes, server side caching has its benefits, especially for large sites.
    For example, you can use memcache to store your query results in memory.
    There are also modules for caching PHP opcode (APC for instance).
    I read somewhere that an opcode cache will be included in PHP6.


    I think the php mimetype is application/x-httpd-php. What do you need that for?
    I have never need that since I primarily use php to send text/html or application/xhtml+xml.
    I don't need it. I found out that text/html works fine; I just assumed that I would need it if my files ended with .php, but I guess that's not the case. When would be a good time to use the PHP mime type, though? Could you give an example?

  • #12
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    One place I can think of is phps files and Apache.
    Code:
    AddType application/x-httpd-php-source phps
    That will show syntax highlighted source code for phps files.

    Using the php mime type, instead of text/html, may allow someone to download your php files. There are other ways to force downloads though (application/octet-stream, for example).
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •