Cache pollution attack is one of the prominent problems for Named Data Networking (NDN). Attackers pollute a cache of NDN by contents which are not popular among normal users. Normal users take more time to obtain contents due to the attack. There are some countermeasures against cache pollution attack in NDN, but most of them focus on full content names. Using full names needs a large amount of storage cost. In this paper, we propose a cache protection method against cache pollution attack based on hierarchy of content name prefixes in Named Data Networking (CPMH). CPMH can defend caches from malicious users and alleviate the influence of attack after detecting it. The purpose of CPMH is maintaining the accessibility of normal users to obtain contents. CPMH alleviates cache hit ratio degradation caused by attack. In CPMH, each router identifies the prefixes of contents requested by attackers based on hierarchy of content name prefixes and protects its own cache. We compare CPMH with the related work by simulation. As a result, we confirm the effectiveness of CPMH against cache pollution attack.