Fix secure context generation in cache