Performance and Security

9

questions

Does a nonce protect against unauthorized access?

No. A nonce protects against CSRF — a forged request on behalf of the user. Whether the user has the right to the action is checked by current_user_can() or an owner check of the resource.

What are cart fragments and why are they criticized?

A mechanism that updates the mini cart with the get_refreshed_fragments AJAX request. It made an uncached server request on every page. In modern versions the script loads only where the classic cart widget is.

What does an object cache give you?

It keeps query results and transients in memory (Redis, Memcached) between requests. Fewer SQL queries on every page, especially for logged-in users and the cart.

What is IDOR in a store?

Insecure Direct Object Reference: a customer changes the order_id in a request and gets someone else's order. The protection is a check that the order belongs to the current user, or access by the order key.

When do you sanitize and when do you escape?

Sanitize on input, before saving. Escape on output, in the output context (HTML, attribute, URL). One doesn't replace the other.

Which metrics are part of Core Web Vitals?

LCP (how fast the main content appears), INP (how fast the page reacts to actions) and CLS (layout stability).

Which WooCommerce tables grow fast?

Sessions (woocommerce_sessions), Action Scheduler jobs and logs, order meta, draft orders. They need cleanup and size monitoring.

Why can lab data differ from field data?

The lab is one run on an emulated device. Field data (CrUX) comes from real users with different devices, networks and caches.

Why can't the cart and checkout be fully cached?

They are personal: the cart, the address, the discounted prices of a specific customer. A page cache would serve one customer another customer's cart. So they are excluded from the cache, and WooCommerce sets cookies that caching plugins and hosts use to bypass the cache for customers.