TTL stands for “Time to Live” in the context of SQL caching. It defines the duration for which cached data remains valid before it is discarded or refreshed. When SQL queries are cached, the results are stored for a period specified by the TTL. Once this period expires, the cached data is considered outdated and must be retrieved and stored anew during the next request.
When using SQL Cache with WP.pro, TTL plays a crucial role in managing cache efficiency. Setting an appropriate TTL ensures that frequently requested data is quickly served without querying the database each time. This reduces the load on the database and improves application response time of your WordPress site. of your WordPress site.
Please note that excessive caching can have negative impacts on areas like the WordPress admin panel or some modules, particularly when updating settings. It is advisable not to set TTL values too high, or to reduce them before making significant changes to plugin settings if problems occur.
SoftTTL vs. HardTTL
SoftTTL and HardTTL are two different mechanisms used in caching systems to manage the validity of cached data.
SoftTTL
SoftTTL defines a period during which cached data is considered fresh and can be served without checking the origin server for updates. After the SoftTTL expires, the cache may still serve the cached data, but it will trigger a background refresh to fetch updated content from the origin server. This ensures that users continue to receive content without waiting for the server to respond, while the cache is updated in the background.
HardTTL
HardTTL sets a strict expiration time for cached data. Once the HardTTL expires, the cached data is considered stale and is not served to users. Instead, the cache will directly fetch the new content from the origin server before responding to user requests. This ensures that users always receive the most up-to-date content but may result in slightly longer wait times when the cache is refreshed.
Summary
SoftTTL allows for continuous content delivery with background updates after expiration.
HardTTL ensures up-to-date content delivery by not serving expired cached data and requiring an immediate update from the origin server.
These mechanisms help balance between providing fresh content and minimizing latency, improving the overall performance and reliability of the caching system.