cache function ?

Discussion in 'Bug Reports' started by furimedia, Aug 15, 2008.

  1. furimedia

    furimedia Well-Known Member

    Hi guys

    I been looking into some type of reverse proxies like squid / varnish and I was wondering, is Litespeed's caching basically the same thing as them?

    I just want a simple caching daemon on the server for better performance. I was wondering how much of a performance boost can I get with it?

    Also if I were to go with varnish, how would i set that up in vhost environment? it seems whatever i do, it just seem to pull out my domains from my DocumentRoot instead of my vhost conf file.

  2. mistwang

    mistwang LiteSpeed Staff

    Yes, 4.0's cache function is equivalent to squid/varnish. It should perform better than those two.
    As to performance gain, it depends on the cache size, cacheable pages, hit rate etc.
  3. furimedia

    furimedia Well-Known Member

    Thanks for the reply.
    But wondering, when do you expect 4.0 to be out of Beta?

    Because I'd really love to start using the cache feature as soon as possible.
  4. mistwang

    mistwang LiteSpeed Staff

    It will take a while, however, the cache function should be pretty stable, 4.0 in beta mainly because the SSI implement need more time to test.
  5. Marcus

    Marcus Well-Known Member

    Possible on standard version?


    I've tried enabling the cache function on the standard version 4.0b2, and that seems to work. However, no caching seems to happen. I've read that you need a 2-cpu license to try the cache function. Can I presume this means that it won't work on the standard version, even though you can set it in the admin panel? If this is correct, would it not be better to identify that you can't use it in the panel itself?

  6. mistwang

    mistwang LiteSpeed Staff

    That's correct. We will tell user this function is not available in the web console for standard edition.
  7. sniperd

    sniperd Member

    FYI - My company uses the cache function in a reverse proxy type setup and were doing 70k page views an hour no problem in production.
  8. muiruri

    muiruri Well-Known Member

    Hi George,

    You mentioned sometime back cache feature in LSWS 4.x would be equivalent to varnish, which is exactly what we need badly! as our varnish equivalent.

    To make use of it, I believe we simply go to; Configuration -> Cache
    menu option, where we have two categories; "Cache Storage Settings" & "Cache Policy"

    (a) At the 1st category, is storage path any folder on my cpanel server, & do I create a folder such as; /home/cache/ ?

    (b) Max Object, what do you recommend?

    (c) On next category when I pass my mouse over icon for "Enable Cache" says;

    "Specify whether to turn on cache for current context, either at server level, virtual host level or directory level."

    But when i click on edit to do select only have "yes" or "no" to enable, and there're no three options as indicated by the footnotes earlier.

    Does this mean we no longer need to worry about the three levels?

    (d) Do you have suggestions or recommendations for parameters to use for Cache Expire Time (seconds) and others which have "yes" & "no" ?

    (e) Once above are done, must we use cache derivatives in Apache you mentioned once;


    And if that's the case, would it be universal for all domains or one has to do this for each domain?

    Which means using apache custom file for each host such as;

    Include "/usr/local/apache/conf/userdata/std/2/cpanel-user/"
  9. mistwang

    mistwang LiteSpeed Staff

    Answers to your questions:
    a) better put the cache directory to a dedicate disk, you can create the cache directory any where you want.
    b) It really up to you, and adjust based on your site, maybe start from 500KB.
    c) If you configure vhost natively, you can set that option at different level, for using with httpd.conf, it does not matter.
    d) It is the same as "CacheMaxExpire", so just set appropriate value for your web app. how long you want one page being cached.
    e) configuration in the default/main server section should be served as default value, you can customize it for each vhost.
  10. muiruri

    muiruri Well-Known Member

    Thanks Geroge,

    What do you think of the following;

    I've created folder on the cpanel backup drive be'se it's accessed much less than the primary drive.

    Therefore created folder at; /backup/cache/

    I thought 1st four settings are all I need, as follows;

    Storage Path: /backup/cache
    Max Object Size: 1024 (this is the minimum menu allows)
    Enable Cache: Yes
    Cache Expire Time (seconds): 86400

    The rest of the settings I left them at "NOT SET"

    (i) Hope this is all I need to do and all sites will automatically start using this feature, right?

    (ii) Also believe if we added a fast drive even say just a 73GB, 15,000 RPM SAS drive, we would get better cache performance than usual 7,200 RPM SATA drives, right?

    (iii) I'll appreciate any additional suggestions/ideas to archive better results.

    ...regds, Sam
  11. mistwang

    mistwang LiteSpeed Staff

    Max Obj Size of 1024 is too small I think. If a page larger than 1K, LSWS will not cache it. Cache Expire time should be shorter, start from 1-5 minutes, just in case that some page should not be cached was cached.

    If you use cPanel, you should rebuild Apache with mod_cache support, then go to "service configuration >> Apache Configuration ", Edit Apache include files, edit "Pre Main Include", add

    CacheRoot ...
    CacheEnable disk /

    It will enable cache for all vhosts configured through httpd.conf .

    The reason to build Apache with mod_cache and mod_disk_cache is that, Apache will fail configuration test if not.

    Yes, using faster disk will help with the performance.

    Be conservative with cache configuration, only let web server to cache the page when the page can be cached. be extremely careful with the option that "Ignore Cache control headers".
  12. muiruri

    muiruri Well-Known Member

    I've now rebuild Apache with mod_cache & mod_disk_cache

    Then gone to cpanel / WHM, to "service configuration >> Apache Configuration ", Edit Apache include files, edit "Pre Main Include"

    Then added two lines;

    CacheRoot /backup/cache/
    CacheEnable disk /

    1st line is where the cache folder is.

    In LSWS on the Configuration -> Cache

    I have Max Object Size = 1024000

    Enable Cache = Yes
    Cache Expire Time (seconds) = 120

    The rest of the settings;

    Cache Request with Query String
    Cache Request with Cookie
    Cache Response with Cookie
    Ignore Request Cache-Control
    Ignore Response Cache-Control

    I have left them as "Not Set"

    The cache folder appears to be growing with some files.

    What do you think of this now?

    How do I check or monitor to see if this is working effectively or efficiently?

    Any additional ideas/suggestions?
  13. ShawnMarck

    ShawnMarck New Member

    I'm only using our LSWS Server for reverse proxies and I am not seeing the cache working either.

    I've enabled caching on the server level, vhost level, context level.

    I set the cache store location.
    Set the max size to 1024000
    Set the expiration to 3600

    I'm still seeing each connection go through to the ext app.

    What am I missing?
  14. mistwang

    mistwang LiteSpeed Staff

    The default cache policy is conservative, do not cache request/response with cookies, do not cache request/response when cache-control does not allow caching.

    So, try a simple page like phpinfo() page first, on client side, check the request/response header with firebug to make sure there is no header that could prevent LSWS from caching the response.

    Once phpinfo() page works, then you can start to check the other pages, and fine tune the cache policy carefully. It is not recommended to ignore the cache control header unless you know what you are doing and the page is safe to be cached.
  15. mistwang

    mistwang LiteSpeed Staff

    If you think LSWS does not cache certain page, you need to check the request/response header see if anything prevent the page being cached.

    Request with Query String? Request Cookie? Response Cookie? Request cache-control? response cache-control?

    If you think a page can be safely cached even with some header can prevent it from being cached, you can adjust the cache policy to force LSWS to cache that page, you may need to create a context for that URL.
  16. muiruri

    muiruri Well-Known Member

    (a) This is what we're using in LSWS;

    Cache Storage Settings
    Storage Path = /backup/cache (using server's backup HD)
    Max Object Size = 1024000

    Cache Policy
    Enable Cache = Yes
    Cache Expire Time (seconds) = 120
    Cache Request with Query String = No
    Cache Request with Cookie = No
    Cache Response with Cookie = No
    Ignore Request Cache-Control = No
    Ignore Response Cache-Control = No

    (b) Then at WHM, Rebuild Apache with mod_cache & mod_disk_cache

    (c) When done, again at WHM, went to;

    Service configuration -> Apache Configuration

    Edit Apache include files -> Pre Main Include

    Selected Apache 2.x

    Then added two lines;

    CacheRoot /backup/cache/
    CacheEnable disk /

    The cache directory has been growing, therefore believe cache is working well.

    Question now is there one of the menu sections in LSWS where I can see or monitor files or data cached Or better still is there a place in LSWS I can see the LSWS using the cache?
  17. mistwang

    mistwang LiteSpeed Staff

    No, not possible to monitor the cache status at this moment. May add it to the real time report in the future release.
  18. canglan

    canglan Member


    Does the VPS license have the cache feature enabled? We have a couple of VPS licenses installed and we cannot get any of them working.

    LSWS cache settings are set. Apache directives are set. The cache directory is still empty.

    How do we go about identifying the cause?
  19. mistwang

    mistwang LiteSpeed Staff

    Cache function is only available for 2-CPU license and above. It is not available for VPS license.
  20. canglan

    canglan Member

    Thank you George. All sorted, caching is working beautifully. :)

Share This Page