• Resolved mark111xyz

    (@mark111xyz)


    First of I want to say that this plugin is very light weight and I like this.

    But, I have a also a problem because it does not let varnish to cache files that this plugin combines and minifies.

    How can I resolve this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Raul P.

    (@alignak)

    Please check if with every page reload, those .js or .css files are changing names. If they are, you probably have a dynamic css or js file, that needs to be excluded.

    If the names stay the same, then it’s something on varnish configuration.
    The plugin cannot interfere with varnish in any possible way.

    What Varnish does is to sit between your users and your webserver, caching all files and pages, as per varnish configuration file.

    FVM generates static js and css files only, which are as normal as any other js or css file in the server. If for some reason Varnish is not caching those files, you may have an exclusion in place for the uploads directory.

    I suggest you look at your varnish configuration, or if you’re not sure, please contact your hosting provider or get a systems administrator to inspect your varnish configuration.

    FVM is basically generating static files only, and it doesn’t communicate with varnish in any way, neither it has the ability to set cache headers to prevent caching.

    Look at your server headers response, and if they are missing, add expires headers to your js and css files. Perhaps, something like this if you’re in apache. https://softstribe.com/wordpress/how-to-add-expires-headers-in-wordpress/

    Thread Starter mark111xyz

    (@mark111xyz)

    Raul, you were right, I have dynamic css and js and that’s why varnish does not cache them.

    Do you know how make css and js not to change. I searched on the web but I was not able to find a solution. Can you help me to exclude the version that comes behind?

    Thanks.

    • This reply was modified 8 years, 4 months ago by mark111xyz.
    Plugin Author Raul P.

    (@alignak)

    Hi,

    Unfortunately, the safest ways would be to hire someone to inspect your theme or plugins and find out where that file comes from.

    If you look at the html “view-source” page, you should be able to see the “handle” name of the css. It looks like this:

    <link rel='stylesheet' id='font-awesome-css' href='//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css?ver=4.3.0' type='text/css' media='all' />

    You have to look at the “id” and remove the -css part, so for this specific example, the handle name is font-awesome.

    You could then exclude this file from loading with https://codex.ww.wp.xz.cn/Function_Reference/wp_dequeue_style

    However, you would need to create a static file for it and enqueue it on the same exact position, using priorities or dependencies.
    I seriously cannot recommend this unless you’re somehow comfortable with basic coding. Also make sure you try this after you made a backup of the site… and preferably, on a staging copy.

    There are some plugins that allow you to dequeue scripts and css files, such as this one: https://ww.wp.xz.cn/plugins/wp-asset-clean-up/
    You would still need to enqueue the proper code in a static file.

    Examples:
    https://code.tutsplus.com/tutorials/loading-css-into-wordpress-the-right-way–cms-20402

    Also bare in mind, some themes load different css code per page dynamically.

    There’s not much you can do if the url of the css file changes from the varnish point of view. It’s a new url every time, therefore is never cached.

    You could setup varnish to ignore the query strings on that particular file or directory, but easiest way is to do that via the free cloudflare.com service.
    You could create a rule to force caching on a specific rule…

    Unfortunately, I cannot help you further with that.

    Thanks for reporting.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘This plugin does not let Varnish to cache’ is closed to new replies.