• Resolved Anonymous User 14978628

    (@anonymized-14978628)


    Hi,

    I really want to use this plugin with Cache Enabler but that plugin seems to strip these headers from the cached page.

    Is it possible to get the two working together? Or would you perhaps know how to setup cache control headers for homepage, posts, category, in htaccess? That would be a great help if you can.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Dan

    (@geekysoft)

    No, it’s not possible to make a caching implementation that disregards the standard HTTP Cache-Control header work with said header. You can ask the plugin vendor to support the Cache-Control header, however.

    The Cache-Control plugin works best if you use a reverse-proxy, web accelerator, content delivery network, or another caching tool that is controlled with the standard HTTP cache mechanism. The header instructs a cache how long it should store items before asking your servers to generate a new updated copy of a page.

    Plugins such as Cache Enabler caches your webpages as static pages on your own server. Which breaks the Cache-Control plugin’s ability to inject HTTP headers. This may save you a millisecond of PHP processing time, but doesn’t actually make your website all that much faster.

    You can read up on HTTP-compliant server-side caching with mod_cache for Apache, the proxy_cache module for NGINX, or Varnish Cache. You can also use a budget content distribution network (CDN) (starting at only 0.04 USD/GB –?which is dirt-cheap). They’ll cache your pages in accordance to your HTTP Cache-Control headers (which is what my plugin helps you configure), and serve your website from 20 cache servers located all around the world. You’ll only need to configure your Cache-Control headers, and your CDN provider will do the caching for you. (Whichever CDN provider you choose to use, ask their support for help with configuring “full-site acceleration”. It’s a 30 minute job.)

    Using a CDN with the Cache-Control plugin will yield the best performance results for the least amount of effort. Configuring and maintaining caching web servers around the globe yourself requires a lot of effort and upkeep.

    I hope this helps.

    • This reply was modified 7 years, 5 months ago by Dan.
    Thread Starter Anonymous User 14978628

    (@anonymized-14978628)

    I’ve already setup my site to run entirely through the cdn so cached pages are also served from cdn and not just things like css, js, images. Doing this halved my page load time, so i fully understand the benefits of doing this which is why your plugin is so useful as it allows me to set longer expiry on posts which don’t change once published, but a shorter expiry on things like the homepage which do change frequently.

    I contacted the developer of the cache enabler plugin telling them that the cache control headers are being stripped, he basically said that this occurs with all the other caching plugins he tested. Not sure if he’s going to fix it or not, but i like the cache enabler plugin as it’s very simple and lightweight.

    I can get this plugin working with litespeed cache plugin, so i can still use the headers output by this plugin fortunately. I was just hoping to be able to use it with cache enabler as a preference.

    Thanks

    Plugin Author Dan

    (@geekysoft)

    Then you shouldn’t need the Cache Enabler plugin at all. Your CDN should be configured to only fetch pages once they expire; at which point WordPress has to generate new pages. Serving old pages generated by the Cache Enabler pluign at this time is redundant.

    Thread Starter Anonymous User 14978628

    (@anonymized-14978628)

    Right, so are you saying that if my site is configured to be served entirely through the cdn that i don’t need a caching plugin at all?

    My thinking was that once a post is published, a page cache is generated from the caching plugin, and that cached page is then served from the cdn. So essentially i’m sending the cdn a static page.

    But if i don’t have a caching plugin, then doesn’t the cdn receive a dynamic page? Or are you saying the cdn will basically convert that dynamic page to a static page?

    There is also the issue of first time visitors to a page that hasn’t yet been cached by the cdn. In this instance it would be better to have a page cached by a caching plugin.

    With your plugin i can configure how long i want a cached page to remain in the cdn cache, so i’m not serving old pages generated by Cache Enabler.

    Just to clarify my existing setup, all my content is generated on the host server and that is what is served on first page view. On subsequent page views all content is served from the cdn.

    Plugin Author Dan

    (@geekysoft)

    The Cache-Control plugin inserts a Cache-Control: max-age=500 header; where 500 is configurable in the plugin and represents the number of seconds a page should be cached. Meaning, a cache — such as a CDN — should serve a cached version of the page for 5 minutes. Meaning that after 5 minutes, the CDN will go back to your server to fetch new copies of your pages. A dynamic page refers to a page where the content changes. If you introduce caching, then your dynamic pages become static — as for what caches are concerned — for a configured amount of time.

    So the Cache-Control plugin does all you need to make WordPress’ dynamic pages cacheable if you already serve your website through a CDN.

    Read up on RFC 7234 to learn how HTTP caching works.

    • This reply was modified 7 years, 5 months ago by Dan.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cache Control htaccess’ is closed to new replies.