Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache-Control values could support bfcache usage? #197

Closed
E-VANCE opened this issue Aug 16, 2023 · 2 comments
Closed

Cache-Control values could support bfcache usage? #197

E-VANCE opened this issue Aug 16, 2023 · 2 comments
Labels

Comments

@E-VANCE
Copy link

E-VANCE commented Aug 16, 2023

This isn't a bug – more of a feature request / question regarding the current Cache-Control-implementation...

Having read up on the browser bfcache this morning and testing our site with Chrome's Dev Tools, I found it isn't comaptible due to no-cache, no-store, must-revalidate.

By default WP Rocket seems to be using max-age=0 and that allows for the bfcache to be applied.

I have adjusted the template file accordingly but was wondering if you see any major downsides when it comes to tweaking the Cache-Control-header in this fashion?

Or maybe the max-age=0 could become the default and all sites would benefit from a bfcache...?

Thanks a lot for providing this config, very helpful! 🙏

@maximejobin
Copy link
Collaborator

I have adjusted the template file accordingly

Is there a reason for changing the template instead of editing the configuration file?

You can change the Cache-Control and add headers by simply editing the configuration. No need to edit the template.

That being said, I will take a look and see if/how the project can be improved!

@maximejobin
Copy link
Collaborator

After reading on BF Cache and the needed modifications, I'm happy to say that Rocket-Nginx is already compatible with BF Caching!

All you have to do is to change the line in your rocket-nginx.ini configuration from:

html_cache_control = "no-cache, no-store, must-revalidate"

To:

html_cache_control = "no-cache, must-revalidate"

Then, run the rocket-parser.php file again, reload the Nginx configuration, and you're done!

For security reasons, I will not change the default configuration to make it compatible with BF Cache. It will be up to the server administrator to validate if the website can have its data in cache.

I tested it on my personal website and it works as shown from the Dev Console > Application tab under the Back/forward cache section (under Background services).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants