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

Investigate better way to prevent snippets from caching #200

Open
sheabunge opened this issue Dec 6, 2024 · 3 comments
Open

Investigate better way to prevent snippets from caching #200

sheabunge opened this issue Dec 6, 2024 · 3 comments

Comments

@sheabunge
Copy link
Member

Is your feature request related to a problem? Please describe

We are curently using the code snippet provided below to display a message on the front end of our website (i.e., contact page) indicating whether our business is open or not.

In order for the code snippet to work, we had to disable caching on our contact page.

Describe the solution you'd like

Is there any way (via code snippet, ajax call) we can execute the code snippet provided below without the need to disable caching on our contact page?

Describe alternatives you've considered

Problem solved with another lightweight plugin: Content No Cache.

Additional context

Transposed from support thread by Generosus: How to Prevent PHP Code from Caching

@sheabunge sheabunge changed the title Investigate better way to prevent snipepts from caching Investigate better way to prevent snippets from caching Dec 6, 2024
@Generosus
Copy link

Generosus commented Dec 6, 2024

Thanks for adding this to your list. I wouldn't spend too much time on this. Initial issue solved via the plugin, Content No Cache.

However, if and when you decide to look into this in more detail, here's what I recommend:

Short-Term Solution:

Create a code snippet (filter) that will allow bypassing the caching of other code snippets (via code snippet ID).

Long-Term Solution:

Modify the plugin settings page to add a new field, titled "Bypass Caching", with an open field next to it where users can enter the affected code snippet ID.

Details: https://prnt.sc/WTC7n_ZG_GnI
Similar to this (example only): https://prnt.sc/aXLIkM-bBbUP

Useful Tip: Our team has worked with PHP/JS developers hired via Upwork to accomplish a similar project. Excellent results, project solved. It saved us a lot of time and money.

Note: As you know, the above will require testing with all major caching plugins and CDNs to ensure no issues.

Hope the above helps.

Cheers!

@sheabunge
Copy link
Member Author

sheabunge commented Dec 6, 2024

Thanks for the additional suggestions, it's really appreciated! This is definitely not the highest on our list of priorities, but I figured it was worth at least recording so we can revisit it at some point in the future.

I think ideally, we will eventually just be able to add an option to the snippet edit screen where you can check a box asking this snippet to be excluded from caching, or even just a flag in the content shortcode/block/widget.

@Generosus
Copy link

Agree! I like the checkbox idea. :) Cheers!

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

No branches or pull requests

2 participants