• Resolved cag8f

    (@cag8f)


    Hello. I am building a site on my local computer, on a virtual nginx server. I am pushing the changes to my live site, on a remote Apache server. I would like to install your plugin and activate its browser caching feature. When I tried to activate it on my local site, I was met with the error:

    Browser Caching is not working properly:

    – Your server may not have the “expires” module enabled (mod_expires for Apache, ngx_http_headers_module for NGINX)
    – Another plugin may be interfering with the configuration

    I don’t have any other caching plugins (but I do have the security plugin Wordfence installed). How can I properly do this?

    Thanks.

    edit: To be clear about my development, I am building the site on my local computer. Every time I make a change, I sync the files to the remove server using git, and push the local database to the remote server using a plugin (WP Sync DB).

    • This topic was modified 5 years, 10 months ago by cag8f.
Viewing 15 replies - 1 through 15 (of 19 total)
  • Hi @cag8f,

    That’s easy. Browser caching in Apache is activated via custom rules, added to the .htaccess file. So you should just manually select Apache server in the Browser Cache module, Activate it. And that’s it. On your local development server it won’t have any effect and browser caching will be disabled, but when the files are synced, and the .htaccess file from local goes to production, browser caching will be enabled there.

    Best regards,
    Anton

    Thread Starter cag8f

    (@cag8f)

    >> So you should just manually select Apache server in the Browser Cache module, Activate it. And that’s it.

    OK. I think that’s what I did. Specifically, on my local site I selected Apache server and ‘automatic’ setup (screenshot). I then encountered the error. Are you saying I should now push the database to my live server, and browser caching on the live server will function as expected? It’s true that I don’t need this feature to function at all on my local server.

    @cag8f,

    If your production supports modifying browser caching via .htaccess – that’s all you need to do. Push to live and verify. You’d still need to click on “re-check status” button in Browser Caching module on live site, to update the status in Hummingbird.

    Best regards,
    Anton

    Thread Starter cag8f

    (@cag8f)

    >> You’d still need to click on “re-check status” button in Browser Caching module on live site, to update the status in Hummingbird.

    OK that all sounds good. But let’s say I do this, and browser caching then becomes active and functioning on my live site. What happens the next time I push from local to live? Will browser caching become disabled again on the live site? I’m trying to avoid having to re-enable browser caching on my live site every time I push from local to live.

    • This reply was modified 5 years, 10 months ago by cag8f.
    • This reply was modified 5 years, 10 months ago by cag8f.

    @cag8f,

    The status is kept in the database. So if you sync dev to production, where there’s no browser caching enabled, the disabled status will be synced as well. To make it all work, you’d need to enable browser caching in your development environment as well.

    Best regards,
    Anton

    Thread Starter cag8f

    (@cag8f)

    >> To make it all work, you’d need to enable browser caching in your development environment as well.

    OK. So I’m back to my original question: How can I enable browser caching in my development environment–which is on an nginx server–then push to my live server–which is on an Apache server–and have browser caching remain enabled on my live server?

    • This reply was modified 5 years, 10 months ago by cag8f.

    Enable browser caching in both Nginx and Apache in your development environment. Caching in Nginx is enabled in server configs, they won’t be synced to production.

    Best regards,
    Anton

    Thread Starter cag8f

    (@cag8f)

    >> Enable browser caching in both Nginx and Apache in your development environment.

    How do I do that? It appears there is a drop down menu that allows me to select Apache or nginx (screenshot. Plus, on my dev site, if I select Apache here, it seems to fail and displays the error:

    >> Browser Caching is not working properly:
    >> Your server may not have the “expires” module enabled (mod_expires for Apache, ngx_http_headers_module for NGINX)

    How can I enable browser caching for both Apache and nginx on my dev site?

    Thanks.

    For Nginx you need to follow the instructions from Hummingbird. There isn’t a way to auto enable browser caching in Nginx from a plugin.

    Thread Starter cag8f

    (@cag8f)

    OK understood on enabling browser caching in nginx. But to confirm, you’re saying that if I enable browser caching for both Apache and nginx on my dev site, then push to my live site, browser caching will be enabled, without any extra steps on my part? In this case, if I have to still login to the live site backend and click a few things, that defeats the purpose of this exercise.

    @cag8f,

    Yes, it will work if:
    1. Development has a working browser caching config in Nginx and the status is properly shown in Hummingbird
    2. Development has an .htaccess file with browser caching rules for Apache
    In this case, after sync you will not need to update anything on production.

    Best regards,
    Anton

    Thread Starter cag8f

    (@cag8f)

    OK thanks for confirming that. Let me give it a shot over the next few days and report back here.

    Thread Starter cag8f

    (@cag8f)

    OK I’m ready to return to this. It’s looking like I won’t be able to enable nginx caching on my local site. So let’s talk workarounds. Consider this procedure:

    1. Ensure browser caching is disabled on my local (nginx) site.
    2. Push database from local site to live (Apache) site.
    3. Manually enable browser caching on live site.

    Would this be a sufficient workaround to ensure browser caching is enabled on my live site? It adds an extra step for me, but it is better than nothing for now.

    Let me know.

    Thanks.

    @cag8f,

    Yes, that will work. Don’t forget the .htaccess file on your local site.

    Best regards,
    Anton

    Thread Starter cag8f

    (@cag8f)

    >> Don’t forget the .htaccess file on your local site.

    OK wait. I currently do *not* sync my .htaccess between local and live–they are two separate files. Is this going to be OK?

    The contents of each are currently quite different. The local version has only:

    # BEGIN WP-HUMMINGBIRD-CACHING

    # END WP-HUMMINGBIRD-CACHING

    While the live version has a fair amount more, including all the lines from the default WordPress .htaccess, as well as some lines I added to enable Gzip compression. How should I handle this?

    To be clear, the live version of .htaccess does *not* contain:

    # BEGIN WP-HUMMINGBIRD-CACHING

    # END WP-HUMMINGBIRD-CACHING

    • This reply was modified 5 years, 10 months ago by cag8f.
Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘How to activate browser caching on local site and push to live site?’ is closed to new replies.