0

Is there a way of not having smoothState cache my pages? I am developing a large news site and since content is added on a daily basis people need to press F5 on all of the pages to view the new content and updated sitebars...

Can I just set cacheLength to 0 or would that beat the point of the entire script?

New to smoothState so this is what I have in my main:

My main.js file

$(function(){
  'use strict';
  var $page = $('#main'),
      options = {
        debug: true,
        prefetch: true,
        cacheLength: 4,
        onStart: {
          duration: 350, // Duration of our animation
          render: function ($container) {
            // Add your CSS animation reversing class
            $container.addClass('is-exiting');
            // Restart your animation
            smoothState.restartCSSAnimations();
          }
        },
        onReady: {
          duration: 0,
          render: function ($container, $newContent) {
            // Remove your CSS animation reversing class
            $container.removeClass('is-exiting');
            // Inject the new content
            $container.html($newContent);
          }
        }
      },
      smoothState = $page.smoothState(options).data('smoothState');
});
Hanna Stone
  • 193
  • 2
  • 11
  • According to the documentation there is a `clear()` method you can use to remove a URL from smoothstate's cache: https://github.com/miguel-perez/smoothState.js#clearurl – Rory McCrossan May 23 '18 at 09:32
  • Thanks @RoryMcCrossan still reading up on the documentation, how would I add the clear() function? I am new to JS also, but do I add that to the function? – Hanna Stone May 23 '18 at 10:28
  • I've not used the plugin so I'm not 100% certain. However from the docs it looks like a separate method, so you would need to call it *after* you instantiate the plugin, like this: `smoothState.clear()`; – Rory McCrossan May 23 '18 at 10:32

0 Answers0