[bd] Cache 1.3.2

Faster and faster.

  1. motowebmaster

    motowebmaster New Member

    I'm not running xf 1.4 yet, but chose to upgrade. It worked fine, but broke the style on the PhotoPost section of my site.

    Sometimes this was happening in the previous version, but a simple reload of the page cleared the issue. This time it wouldn't go away, and have disabled the add-on.

    Let me know what information I can provide.
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @motowebmaster Looks like a conflict issues but I don't have that add-on so I'll need to check on your site. Please start a conversation with me with your site info. Sorry for the inconvenience.
       
  2. Mick West

    Mick West New Member

    The Defer JavaScript option broke my site, as it ignored HTML comments, and I had some commented out stuff, like:

    Code:
    <!--
    <script  src="https://code.jquery.com/jquery-1.10.2.min.js"></script> 
    -->
    
    This JS should not be loaded, but with the defer feature, it extracted the script from the comment.

    I suggest making a second copy of the html, stripping comments from that, run your defer code on the un-stripped version (so you don't remove any comments that might be needed for other reasons), but only move scripts that appear in both copies.
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Mick West Doing that will cause a performance hit across the site so for now, please use blacklist to ignore your commented out script. It is an edge case anyway. I will try to come up with a better way to do this.
       
      john_the_tester likes this.
      1
  3. Mick West

    Mick West New Member

    I actually had a quite a bit of commented out stuff, as I experiment a lot, so I've just disabled the defer option.
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Mick West Ah I see your point. Sorry for the inconvenience.
       
      john_the_tester likes this.
      1
  4. Arthur Spooner

    Arthur Spooner New Member

    Hi @xfrocks,

    thanks for the addon. Are there any plans to make it more intelegent? So that the (main site / thread / forum) cache is purged if a new post/thread was created/edited.

    Regards
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Arthur Spooner There are plans but invalidating cache that way is currently not planned. Mostly because it's hard to track all pages of a forum. If we track by thread id, there number of threads may get too big to keep track of. Therefore currently the add-on doesn't do cache auto invalidation in anyway.
       
  5. Arthur Spooner

    Arthur Spooner New Member

    You could put the cache in database with additional fields as kind of cachegroups. Of course you would have a db query to fetch the cache, but a db query is faster than a file read. Also you would be able to purge multiple caches depending on new posts or threads.

    You could do something like this:

    DB definition:
    Code:
    CREATE TABLE bd_cache (cache_key varchar(255) not null default '', cache_content longtext not null, cache_time timestamp not null default current_timestamp, page_type varchar(255) not null default '', page_id int unsigned not null default 0, PRIMARY KEY (`cache_key`), KEY k_pagetype (`page_type`), KEY kc_pagetype_pageid (`page_type`, `page_id`));
    If a new page is cached (pseudocode):
    Code:
    
    // based on page type
    
    // if page is thread
    $pageType = 'thread';
    $pageID        = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
    bdCache_Model_Cache::save($output, $pageType, $pageID);
    
    // if page is forum
    $pageType = 'forum';
    $pageID        = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
    bdCache_Model_Cache::save($output, $pageType, $pageID);
    
    // if page is mainpage
    $pageType = 'forummain';
    $pageID        = 0;
    bdCache_Model_Cache::save($output, $pageType, $pageID);
    
    
    If a new thread is created:
    Code:
    $pageType = 'forum';
    $pageID        = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
    bdCache_Model_Cache::purge($pageType, $pageID);
    
    $pageType = 'forummain';
    $pageID        = 0;
    bdCache_Model_Cache::purge($pageType, $pageID);
    
    ...
    
    
    If a new post is created:
    Code:
    $pageType = 'thread';
    $pageID        = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
    bdCache_Model_Cache::purge($pageType, $pageID);
    
    $pageType = 'forum';
    $pageID        = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
    bdCache_Model_Cache::purge($pageType, $pageID);
    
    $pageType = 'forummain';
    $pageID        = 0;
    bdCache_Model_Cache::purge($pageType, $pageID);
    
    ...
    
    
    The cronjob could also purge invalid cache, based on the timestamp in the database, to avoid useless cache for pages which are viewed only once.

    Best regards
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Arthur Spooner Actually it is more complicated than that because there are many more variables for caching (for example filter in forum view) and make it hard to keep track and purge all related pages correctly. But using a separated table for caching is a planned feature for different reason, not just purging. I will see if it is possible to do purging with that.
       
    2. Arthur Spooner

      Arthur Spooner New Member

      Arthur Spooner @xfrocks This could be solved by using the URL as cache_key :)

      Best regards
       
    3. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Arthur Spooner The problem is, if you use the url as the cache key, you cannot figure out all urls when a thread is updated. In fact, url is being used in cache key for now, that's why the add-on cannot invalidate caches. Hmm.
       
    4. Arthur Spooner

      Arthur Spooner New Member

      Arthur Spooner @xfrocks Thats the reason why you would add the fields page_type and page_id to store the threads for different urls. Please take a look at my pseudocode above.
       
    5. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Arthur Spooner When a thread is updated, not only the parent forum is changed, its parent changed too (the last post section in the forum list) so the add-on will also have to traverse the node hierarchy to invalidate all related nodes. And when a post is updated, it has to do it again with the thread too. And all pages of each of those contents... It's doable but I'm a bit worried about the performance hit from that. Also, a new option is to store cached page in file system and make use of .htaccess to serve cached page without going through PHP, making it harder to invalidate cache (and bigger performance hit).
       
  6. radu

    radu New Member

    may I install this addon on two sites? thank you
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @radu Yes, you can.
       
      radu likes this.
      1
  7. woody

    woody New Member

    defer javascript...I've had to disable since it repositions all my Google Doubleclick for Publishers DFP tags to the bottom of the page (and no ads show) - had anyone else noted this and found a fix?

    Thanks :)
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @woody You can enter dfp tags into blacklist option for the defer to ignore. They will be kept in place.
       
  8. woody

    woody New Member

    Fixed I believe - thanks!

    my blacklist, using sync DFP tags:
    Code:
    google_ad
    show_ads.js
    document.write
    gpt.js
    googletag.defineslot
    googletag.display
    googletag.pubads
    googletag.enableServices
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @woody I think "googletag" is enough. You don't need all 4 entries.
       
  9. Nosxxx

    Nosxxx New Member

    May you add xenforo media gallery and featured thread support ?

    Maybe you also add a function to use s3 and cloudfront for caching ?
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Nosxxx Which page are you looking for to be cached?
      If you have the [bd] Data Storage add-on, CSS files can be served from S3 / CloudFront.
       
  10. Nosxxx

    Nosxxx New Member

    Okay, is the DataStorage addon compatible with attachment store ?
    I don't want to have the attachments twice in s3 ^^.
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @Nosxxx Yes, they are compatible with each other. Of course, the files are not stored twice.
       
  11. mark

    mark New Member

    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @mark Weird. Couldn't think of a reason for it to do that. What is your configuration for the add-on?
       
  12. nodle

    nodle New Member

    I posted this over on the official site.

    When I enable the .CSS to file I am getting this error on GTmetrix. When I disable my score actually goes up. Anyone know why? Or how to fix that?

    Code:
    Remove the following redirect chain if possible:
    
    http://www.mysite.com/css.php?css=EXTRA&style=122&dir=LTR&d=1438791134
    http://www.mysite.com/data/bdCache/css/1438791134/407ed7ae13e2ffb119e834c8699edcf4.css
    
    
    Remove the following redirect chain if possible:
    
    http://www.mysite.com/css.php?css=dark_azucloud,login_bar,moderator_bar,node_category,node_forum,node_list,rellect_favicon,sidebaravatars_sidebar_online_users,uix_welcomeBlock&style=122&dir=LTR&d=1438791134
    http://www.mysite.com/data/bdCache/css/1438791134/1aca10f12e68f85da014e7b7a2e56505.css
    
    
    Remove the following redirect chain if possible:
    
    http://www.mysite.com/css.php?css=uix,uix_style&style=122&dir=LTR&d=1438791134
    http://www.mysite.com/data/bdCache/css/1438791134/253c76eb236cb32835ad8fb4a5fddeba.css
    
    
    Remove the following redirect chain if possible:
    
    http://www.mysite.com/css.php?css=xenforo,form,public&style=122&dir=LTR&d=1438791134
    http://www.mysite.com/data/bdCache/css/1438791134/89dcd82d9171becfa136bf1380d4ae31.css
     
  13. xfrocks

    xfrocks XenForo rocks!
    Staff Member

    @nodle, that is normal. The redirect is removed the next time the page is rendered. Try refreshing a few times, you should see the data/bdCache link instead of the css.php one.
     
    1. nodle

      nodle New Member

      nodle @xfrocks I guess I just needed to be more patient. After about 10 minutes it wen't away. Thanks for the great add-on @xfrocks . I hope you keep updating and supporting it. Thanks again for the great work! :)
       
    2. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @nodle Please note that if you are using page caching, the whole page will be kept (with the css.php links) until the cache expires.
       
  14. Jack Roy

    Jack Roy New Member

    is it compatible with xenforo 1.5 ??
     
    sage57 likes this.
  15. Finexes

    Finexes New Member

    Hello,

    thanks for this great add-on! I just have one tiny issue:

    I have a HTML widget in WidgetFramework that displays a TeamSpeak viewer. When clicking on "Show", the widget slides down and displays the viewer, clicking "Hide" let the widget slide up. Before, everything worked great, after installing [bd] Cache, the widget stopped sliding. This is the HTML code:

    HTML:
    <div style="text-align: center"><a id="show-viewer" onclick="false"><span class="button primary">Anzeigen</span></a></div>
    
    <div id="viewer" style="display: none">
    
    <div id="ts3viewer_1048589"></div>
    <script type="text/javascript" src="https://static.tsviewer.com/short_expire/js/ts3viewer_loader.js"></script>
    <script type="text/javascript">
    <!--
    var ts3v_url_1 = "https://www.tsviewer.com/ts3viewer.php?ID=1048589&text=000000&text_size=12&text_family=1&js=1&text_s_weight=bold&text_s_style=normal&text_s_variant=normal&text_s_decoration=none&text_s_color_h=D15304&text_s_weight_h=bold&text_s_style_h=normal&text_s_variant_h=normal&text_s_decoration_h=none&text_i_weight=normal&text_i_style=normal&text_i_variant=normal&text_i_decoration=none&text_i_color_h=D15304&text_i_weight_h=normal&text_i_style_h=normal&text_i_variant_h=normal&text_i_decoration_h=none&text_c_weight=normal&text_c_style=normal&text_c_variant=normal&text_c_decoration=none&text_c_color_h=D15304&text_c_weight_h=normal&text_c_style_h=normal&text_c_variant_h=normal&text_c_decoration_h=none&text_u_weight=bold&text_u_style=normal&text_u_variant=normal&text_u_decoration=none&text_u_color_h=D15304&text_u_weight_h=bold&text_u_style_h=normal&text_u_variant_h=normal&text_u_decoration_h=none";
    ts3v_display.init(ts3v_url_1, 1048589, 100);
    -->
    </script>
    
    </div>
    
    <script>
        (function ($) {
              $(document).ready(function() {
              $("#show-viewer").click(function () {
                 if ($('#viewer').is(":visible")) {
                     $(this).html($(this).html().replace(/Ausblenden/, 'Anzeigen'));
                 } else {
                     $(this).html($(this).html().replace(/Anzeigen/, 'Ausblenden'));
                 }
                 // Do it afterwards as the operation is async
                 $("#viewer").slideToggle("slow");
              });
          });
      })(jQuery);
    </script>
    Any idea how to fix this?

    Thanks in advance!
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @TRGCommunity Maybe add "viewer" into your blacklist option for the Defer JS?
       
  16. Finexes

    Finexes New Member

    Thanks for your answer, I tried that, but that didn't fix the issue :(

    I noticed that there must be a problem with the TeamSpeak viewer code. When I remove it and use the following code, everthing is fine:

    HTML:
    <div style="text-align: center"><a id="show-viewer" onclick="false"><span class="button primary">Anzeigen</span></a></div>
    
    <div id="viewer" style="display: none">
    
    Hello World
    
    </div>
    
    <script>
        (function ($) {
              $(document).ready(function() {
              $("#show-viewer").click(function () {
                 if ($('#viewer').is(":visible")) {
                     $(this).html($(this).html().replace(/Ausblenden/, 'Anzeigen'));
                 } else {
                     $(this).html($(this).html().replace(/Anzeigen/, 'Ausblenden'));
                 }
                 // Do it afterwards as the operation is async
                 $("#viewer").slideToggle("slow");
              });
          });
      })(jQuery);
    </script>
    Do you have an idea why?
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @TRGCommunity So you removed part of the code and it still works?! Well, keep it that way then :)
       
  17. Finexes

    Finexes New Member

    Well, I removed the whole TeamSpeak viewer code and replaced it with 'Hello World', just to test where the problem is :D But that's no solution
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @TRGCommunity So I have just copied your html and put it in a widget, then enabled Defer JS from [bd] Cache and it worked perfectly fine... Maybe you should send me your site url via conversation, I will come by and take a look.
       
      RoldanLT likes this.
      1
  18. Finexes

    Finexes New Member

    That'd be great, I'll send you a pc asap, thanks for looking into this! :)
     
    xfrocks likes this.
  19. tintolio

    tintolio New Member

    Hi

    I purchased you addon, and was just testing it. Really impressive results. Thanks for that.
    But i got this errors on xenforo's logs, related to your cache addon.
    Can you check it, please?
    Code:
    ErrorException: unserialize(): Error at offset 20 of 102400 bytes - library/bdCache/Model/Cache.php:237
    Generated By: Cuenta desconocida, Hace un momento
    #0 [internal function]: XenForo_Application::handlePhpError(8, 'unserialize(): ...', '/backup/data/we...', 237, Array)
    #1 /backup/data/websites/antronioforo/html/library/bdCache/Model/Cache.php(237): unserialize('a:7:{s:6:"outpu...')
    #2 /backup/data/websites/antronioforo/html/library/bdCache/Model/Cache.php(119): bdCache_Model_Cache->_internalData_load('9d83dc1b13a035c...')
    #3 /backup/data/websites/antronioforo/html/library/bdCache/Core.php(148): bdCache_Model_Cache->load('ffbea372c5eb94c...', 1)
    #4 /backup/data/websites/antronioforo/html/library/bdCache/Listener.php(116): bdCache_Core->getCached()
    #5 [internal function]: bdCache_Listener::front_controller_pre_dispatch(Object(XenForo_FrontController), Object(XenForo_RouteMatch))
    #6 /backup/data/websites/antronioforo/html/library/XenForo/CodeEvent.php(90): call_user_func_array(Array, Array)
    #7 /backup/data/websites/antronioforo/html/library/XenForo/FrontController.php(132): XenForo_CodeEvent::fire('front_controlle...', Array)
    #8 /backup/data/websites/antronioforo/html/index.php(13): XenForo_FrontController->run()
    #9 {main}
    array(3) {
      ["url"] => string(89) "http://www.antronio.cl/threads/miss-bumbum-andressa-urach-el-costo-de-esa-colita.1199873/"
      ["_GET"] => array(1) {
        ["/threads/miss-bumbum-andressa-urach-el-costo-de-esa-colita_1199873/"] => string(0) ""
      }
      ["_POST"] => array(0) {
      }
    }
    thanks
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @tintolio Looks like an issue with the cache backend. How often are you getting this error?
       
    2. tintolio

      tintolio New Member

      tintolio @xfrocks 10, 30 minutes or 1 hours .

      [​IMG]
       
  20. tintolio

    tintolio New Member

    ¿?
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @tintolio Please try updating to the recently released version (v1.1.0) and use these in config.php

      PHP:
      $config['bdCache_forceFile'] = true
       
Loading...