Add cache limit to prevent memory hogging