• Resolved Rasso Hilber

    (@nonverbla)


    Hi there!

    Sorry in advance for this pile of text.

    Today I discovered that I can modify the Cache-Control header in expert-mode inside the wp-content/cache/.htaccess file by setting the constant WPSC_CACHE_CONTROL_HEADER in my wp-config.php.

    I am doing this now:

    
    define('WPSC_CACHE_CONTROL_HEADER', 'max-age=300, private');
    

    It’s working fine, the Header gets written to the .htaccess file and sent to my browser for cached requests. But then I noticed this line in the same .htaccess:

    
    ExpiresByType text/html A3
    

    “A3” translates to “access plus 3 seconds”, right? If I understand these Headers correctly, now my custom max-age directive can’t be respected due to the 3 seconds ExpiresByType, right?

    So basically I would need a constant to also change the ExpiresByType Header. I’m imagining something like this:

    
    define('WPSC_EXPIRES_HTML_HEADER', 'access plus 300 seconds');
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Mark (a11n)

    (@thingalon)

    Hi @nonverbla,

    Thanks for writing in. It does appear that you’re right; the ExpiresByType value is hard-coded, while the Cache-Control heading can be freely modified by advanced users.

    We’re having a quick internal debate about how best to handle this, but we’ll explore a fix for this in a future version of WP Super Cache.

    I’ll let you know once we have a better answer for you.

    Thread Starter Rasso Hilber

    (@nonverbla)

    Hi @thingalon ,

    Thanks for your answer! Looking forward to your hear about your findings.

    Best,
    Rasso

    Thread Starter Rasso Hilber

    (@nonverbla)

    Hello @thingalon , I have put some more thought into this after tackling the other issue over here. For now, I have resorted to using a custom class to be able to completely customize the .htaccess file that wp super cache generates. It hooks into the action wp_cache_cleared and will do two things:

    1. Inject a block with custom directives that I can fully control
    2. Modify the Cache-Control header and the ExpiresByType directive inside the supercache block

    I’ll dump the class here for future reference link to a gist of what I’m doing here:

    https://gist.github.com/hirasso/254c5ca2f7464d7b65d3905524bb755d

    • This reply was modified 1 year, 8 months ago by Rasso Hilber.
    • This reply was modified 1 year, 8 months ago by Rasso Hilber. Reason: removed inline code block, linked to a GH Gist instead
    Plugin Contributor Mark (a11n)

    (@thingalon)

    Hi @nonverbla,

    Just a quick update to let you know that our fix is still on its way.

    I’m aiming to make ExpiresByType automatically set by max-age= Cache-control rules, and add the ability to override headers and expiry rules in the htaccess file via filters.

    If you’re curious to see a preview, take a look at the PR. There’s even an example in there for adding custom Accept-ranges headers 😉

    • This reply was modified 1 year, 7 months ago by Mark (a11n).
    Thread Starter Rasso Hilber

    (@nonverbla)

    Wow @thingalon , that’s such good news!! 🎉 I’ll be sure to check it out end report back over on GitHub.

    Thanks so much for listening and reacting so quickly.

    Plugin Contributor Mark (a11n)

    (@thingalon)

    Hi @nonverbla – I just wanted to let you know that we released Super Cache 1.9.3, which now includes these options. You can see the documentation for it in the wiki.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Allow filtering the .htaccess-entry `ExpiresByType text/html` for expert mode’ is closed to new replies.