Both Blender and (most) OpenGL drivers do some amount of caching. If the shader graph compiles to the exact same GLSL shader code as another material that can speed things up.
On the OpenGL driver level, that could even be a a material that you created a few days ago in another .blend file, since the cache is saved to disk.
Caching is not based on partial similarities, it must be an exact match. However slightly different shader graphs may compile to the exact same code.