How to cache a page with custom template without html tags
-
Hi everybody,
I am using page cache, and I would like the sidebar of my cached pages to be able to load dynamic content with ajax from a json file (which basically contains the list of latest posts, etc.). Everything works, except when it comes to caching the json file.
The trick I am currently using is to have a dummy page (ie, one I create at wp-admin/edit.php?post_type=page) rendered in a jsoncontent.php “template”. The template is really a php file that generates some json, and never uses the dummy page.
Unfortunately, W3 Total Cache refuses to cache my page if there is no <html><body> … </body></html> tags in the page template. Without modifying anything else, if I add these tags around my json string in jsoncontent.php (which, of course, I do not want to do), the cache works fine. So, is there any reason why W3 Total Cache requires what it caches to be actual html content?
Or does anybody know of a better way to cache some json that is to be loaded dynamically by other cached pages?
Thank you very much,
Nauhaie
- The topic ‘How to cache a page with custom template without html tags’ is closed to new replies.