• Resolved unicco

    (@unicco)


    Hi. I bought the cache-plugin months ago. At that time, I were experiencing some problems with the cache-plugin returning the response incorrectly. However, I didn’t have the time to look deeper into this issue, before now.

    I’ve just installed the newest version of ALM + cache (the previous error has been fixed it seems). However, whenever I navigate through my category-pages (with cacheplugin activated) it returns the same content for every page. For instance, if I started in my /stearinlys/kalenderlys, this cache is being written correctly to my dir. If I refresh this page, the same content is being displayed (which ofcourse is correct). However, if I afterwards navigate to a new category, the content from the previous category is being displayed.

    I’ve spend some hours to troubleshooting this error, but I’ve to be honest, I’m pretty confused about how this cache is suppose to work.

    function alm_cache_file dosen’t take any parameters, where the url (or category-slug) are taking into consideration. It only differs from the actual page-number /page1/2, etc… When I go to your javascript-file:

    alm.AjaxLoadMore.loadPosts = function () {
     if(!alm.disable_ajax){ // Check for ajax blocker
    	 if(!alm.paging){
    		alm.button.addClass('loading');
    		if(alm.button_loading_label !== false){
    		alm.button.text(alm.button_loading_label);
    		}
    	}
    	alm.loading = true;
    
    	// If cache = true && cache_logged_in setting is false
    	if(alm.cache === 'true' && !alm.cache_logged_in){
    
    	   var cache_page;
    
    	   if(alm.init && alm.seo && alm.isPaged){
    		  // If the request a paged URL (/page/3/)
    		  var firstpage = '1';
    		  cache_page = alm.cache_path + '/page-' + firstpage +'-'+ alm.start_page +'.html';
    
    	   } else {
    		  // standard request url
    		  cache_page = alm.cache_path + '/page-' + (alm.page + 1) +'.html';
    	   }
    
    	   $.get(cache_page, function( data ) {
    		  alm.AjaxLoadMore.success(data, true); // data contains whatever the request has returned
    	   }).fail(function() {
    		  alm.AjaxLoadMore.ajax('standard');
    	   });
    
    	} else { // Standard ALM query
    
    	   alm.AjaxLoadMore.ajax('standard');
    
    	}
        }
    };

    Shouldn’t this codestructure contains a precondition, here: if(alm.cache === 'true' && !alm.cache_logged_in){, which actually checks whether a cached version exist? It keeps sending me to the else-part (// standard request url), which just returns the same cached version (from the previous category). Here the cache_page just keeps being assigned with the same values, as no variables contain the url, slug, term (or whatever), which would make a difference in the cache_page-variable. As far as I can see, it’s pretty obvious why the same content (~ cached file) is being retrieved from the $.get-call.

    However, I might have misunderstood this completely. I can just conclude that the cache-plugin still dosen’t work. Can you help me out?

    I’m using the following shortcode:

    echo do_shortcode( '[ajax_load_more 
    	cache="true" 
    	cache_id="5449479887"
    	id="ordinary" 
    	scroll_distance="-300" 
    	css_classes="products clearfix products-3" 
    	order="DESC" 
    	orderby="meta_value_num menu_order date" 
    	meta_key="total_sales" 
    	post_type="product" 
    	posts_per_page="9" 
    	taxonomy="product_cat" 
    	taxonomy_terms="' . $cat_slug . '" 
    	taxonomy_operator="IN" 
    	transition_container="false"]' );
    • This topic was modified 7 years, 10 months ago by unicco.
    • This topic was modified 7 years, 10 months ago by unicco.
    • This topic was modified 7 years, 10 months ago by unicco.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    HI unicco,
    Are you passing a unique cache_id for each category? If not, the cache will be the same for all cats.

    $cat = get_query_var('cat');
    $category = get_category ($cat);
    $cat_slug = $category->slug;
    echo do_shortcode('[ajax_load_more cache="true" cache_id="category_'. $cat_slug .'"]'); 
    

    Make sense?

    Thread Starter unicco

    (@unicco)

    Thanks for the quick reply. This actually did it the trick! I really wasn’t aware of, that I had to differ the cache_id for each category. As far as I remember, your docs state something differently. I might have misunderstand that.

    Well the important part is, that it seems to work properly now. I’ll try to push the changed into live version, and see the result.

    Thread Starter unicco

    (@unicco)

    The error from last time still exist. On my local apache (XAMPP) server things works fine. But the cache-plugin is messing everything up on the live version, where I’m running nginx and hhvm. I’ve adjusted chmod and chown, but dosen’t change anything. I’ll try to look into this.

    Thread Starter unicco

    (@unicco)

    Hi again. It seems the error was caused by “All 404 Redirect to Homepage”-plugin. Everything is now working as intended – it seems. Actually really nice with the customizable cache_id. I ended up with 4 variables defining my cache_id, as I’ve different prices (vary discount and vat), qtranslatex-language and currencies. So terrific I’m able to build up different cache’s for each set of rules.

    Just one more question. Is it possible to build up the cache up automatically? Could be pretty awesome with some preloader-starter (as wp-rocket uses), which crawls the site, and builds up all caches.

    • This reply was modified 7 years, 10 months ago by unicco.
    Plugin Author Darren Cooney

    (@dcooney)

    Just one more question. Is it possible to build up the cache up automatically? Could be pretty awesome with some preloader-starter (as wp-rocket uses), which crawls the site, and builds up all caches.

    This would be a pretty nice feature. I’d never actually considered this. I’ll add it to my enhancement board.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cache returns the same page for every category’ is closed to new replies.