How to Cache ACF Fields?

Power Of Custom Fields

How to Cache ACF Fields?

Webtech Nepal Oct 14, 2022 846 views

How to Cache ACF Fields?

ACF (Advanced Custom Fields) is a plugin to create user-friendly custom fields and make website fields rapidly without touching the database. Visit their website to learn more.

Cacheable fields save ACF field group and field attributes as JSON files with a file name like group_6335ad67c484f.json within your theme folder. Now that the JSON file exists, ACF will load the relevant field group and field attributes from this file which reduces the number of database calls during your page load. It also improves the loading speed in both the front-end and back-end.

1. Create a folder named as acf-json in your main theme folder

acf json

When you create a folder called acf-json now, every time you save a field group and field attributes, it will create a JSON file in that folder automatically. For existing Field Groups, open all one by one and re-save them.

2. Sync Changes

Automation process will be apply for sync changes of the field group and field attributes.

3. Security

If you wish to hide your field group or field attributes from the public, simply add an empty index.php file to your acf-json folder.

theme-folder/acf-json/index.php

<?php

// Silence is golden.

?>

4. Conclusion

You can apply this tips on all your websites that use ACF Plugin.