Tagged: Page Fragment Caching
- AuthorPosts
Thymo
GuestHi,
I’m having issues with fragmented page caching. For example, I need to change a tag based on the URL. I put the change script inside a changeTag() function because it seems impossible to simply wrap mfunc around the script. I added the following code in my PHP, but get_the_ID() appears to be returning empty. Is there a way to pass variables into the function?
<!– mfunc testest –>
echo changeTag(get_field(“tag”, get_the_ID()));
<!– /mfunc testest –>Marko Vasiljevic
KeymasterHello Thymo,
Thank you for reaching out and I am happy to help!
For Page Fragment Caching in the W3 Total Cache, the comment/code blocks should be added to your theme template files as HTML and not within the PHP open () tags, as it will cause a PHP parse error/syntax error. Do not include any sensitive information in your code fragments; the code can be revealed if W3 Total Cache is deactivated, the Page Cache is changed to use an incompatible storage engine, or the defined W3TC_DYNAMIC_SECURITY string value is changed or not defined.Page Fragment Cache cannot be used in combination with Page Cache mode Disk: Enhanced because that mode will load the cached page directly from Apache or Nginx. We recommend using Disk: Basic, which will run PHP to process the requests with the benefit of speeding up responses by loading a cached page instead of building the page from scratch. You can use Page Cache engines Redis or Memcached on dedicated or VPS servers as well.
This being said, can you please confirm that the comment is outside of php tags and which caching method is used?
Thanks!
- AuthorPosts