[guided]We choose the cutoff so that the weak equation measures the gradient only where we need it. Set $\delta := R-r > 0$ and $B_R := B(x_0,R)$. Choose $\zeta: U \to [0,1]$ with $\zeta \in C_c^\infty(B_R)$, $\zeta=1$ on $B(x_0,r)$, and $|\nabla \zeta(x)| \le C_0\delta^{-1}$ for every $x \in U$, where $C_0>0$ depends only on the dimension.
Let $K := \operatorname{supp}\zeta$ and choose an open set $W$ with $K \Subset W \Subset U$. Since $u \in H^1_{\mathrm{loc}}(U)$ and $f \in L^2_{\mathrm{loc}}(U)$, we have $u \in H^1(W)$ and $f \in L^2(W)$. The function $\zeta^2u$ belongs to $H^1_0(W)$, so by the definition of [Sobolev spaces with zero trace](/page/Sobolev%20Space) there are functions $\phi_k \in C_c^\infty(W)$ with $\phi_k \to \zeta^2u$ in $H^1(W)$. Extending $\phi_k$ by zero to $U$, applying the weak formulation, and passing to the limit using the $L^2(W)$ [Cauchy-Schwarz Inequality](/theorems/432) gives
\begin{align*} \int_{B_R} \nabla u \cdot \nabla(\zeta^2u) \, d\mathcal{L}^n = \int_{B_R} f\zeta^2u \, d\mathcal{L}^n. \end{align*}
By the [Product Rule for Weak Derivatives](/theorems/3098),
\begin{align*} \nabla(\zeta^2u) = \zeta^2\nabla u + 2\zeta u\nabla \zeta. \end{align*}
Substitution and the Euclidean [Cauchy-Schwarz Inequality](/theorems/432), applied pointwise to $\nabla u \cdot \nabla\zeta$, give
\begin{align*} \int_{B_R} \zeta^2|\nabla u|^2 \, d\mathcal{L}^n \le 2\int_{B_R} \zeta |u| |\nabla u| |\nabla \zeta| \, d\mathcal{L}^n + \int_{B_R} |f|\zeta^2|u| \, d\mathcal{L}^n. \end{align*}
Now apply [Young's Inequality](/theorems/244) in the pointwise form
\begin{align*}
2ab \le \frac{1}{2}a^2+2b^2
\end{align*}
with $a:=\zeta|\nabla u|$ and $b:=|u||\nabla\zeta|$. This yields
\begin{align*} \frac{1}{2}\int_{B_R} \zeta^2|\nabla u|^2 \, d\mathcal{L}^n \le 2\int_{B_R} |u|^2|\nabla \zeta|^2 \, d\mathcal{L}^n + \int_{B_R} |f|\zeta^2|u| \, d\mathcal{L}^n. \end{align*}
Using $|\nabla\zeta| \le C_0\delta^{-1}$ and multiplying by $2$ gives
\begin{align*} \int_{B_R} \zeta^2|\nabla u|^2 \, d\mathcal{L}^n \le 4C_0^2\delta^{-2}\int_{B_R} |u|^2 \, d\mathcal{L}^n + 2\int_{B_R} |f|\zeta^2|u| \, d\mathcal{L}^n. \end{align*}
Apply [Young's Inequality](/theorems/244) again, now in the form $2ab \le a^2+b^2$ with $a:=\delta |f|\zeta$ and $b:=\delta^{-1}|u|\zeta$. Since $0\le \zeta\le 1$,
\begin{align*} \int_{B_R} |f|\zeta^2|u| \, d\mathcal{L}^n \le \frac{\delta^2}{2}\int_{B_R} |f|^2 \, d\mathcal{L}^n + \frac{1}{2\delta^2}\int_{B_R} |u|^2 \, d\mathcal{L}^n. \end{align*}
Combining the preceding two estimates gives
\begin{align*} \int_{B_R} \zeta^2|\nabla u|^2 \, d\mathcal{L}^n \le (4C_0^2+1)\delta^{-2}\int_{B_R} |u|^2 \, d\mathcal{L}^n + \delta^2\int_{B_R} |f|^2 \, d\mathcal{L}^n. \end{align*}
Finally, $\zeta=1$ on $B(x_0,r)$ and the integrand is non-negative, so restricting from $B_R$ to $B(x_0,r)$ and recalling $\delta=R-r$ gives the claimed Caccioppoli inequality with $C:=\max\{4C_0^2+1,1\}$.[/guided]