Welcome Guest, Not a member yet? Register   Sign In
Cache best practice?
#2

Your approach looks good! Here's a confirmation and some additional tips for caching with user input validation:

Yes, using a cache key derived from sanitized user input (like your $slug) is a common practice.  Cache libraries often have built-in validation methods (like static::validateKey).  Trust but verify is a good approach -  letting the cache library handle basic validation but also validating the slug existence in your application logic for an extra layer of security.

Here are some resources for best practices on caching with user input validation:

OWASP Cache Invalidation https://owasp.org/omegle/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/04-Authentication_Testing/06-Testing_for_Browser_Cache_Weaknesses
Key Considerations for Caching https://stackoverflow.com/questions/7441...issing-key
Reply


Messages In This Thread
Cache best practice? - by CIDave - 02-27-2024, 03:27 AM
RE: Cache best practice? - by BhambriRohunu - 04-24-2024, 11:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB