4. In the right triangular prism $A_{1} B_{1} C_{1}-A B C$, $\angle B A C = \frac{\pi}{2}, A B = A C = A A_{1} = 1$. Given that $G$ and $E$ are the midpoints of $A_{1} B_{1}$ and $C C_{1}$ respectively, and $D$ and $F$ are moving points on segments $A C$ and $A B$ (excluding the endpoints). If $G D \perp E F$, then the range of the length of segment $D F$ is ( ).
(A) $\left[\frac{1}{\sqrt{5}}, 1\right)$
(B) $\left[\frac{1}{5}, 2\right)$
(C) $[1, \sqrt{2})$
(D) $\left[\frac{\sqrt{5}}{5}, \sqrt{2}\right)$
4. A.

Taking $A$ as the origin, $AB$ as the $x$-axis, $AC$ as the $y$-axis, and $AA_1$ as the $z$-axis to establish a spatial rectangular coordinate system, we have
$$
\begin{array}{l}
F\left(t_{1}, 0,0\right)\left(0<t_{1}<1\right), E\left(0,1, \frac{1}{2}\right), \\
G\left(\frac{1}{2}, 0,1\right), D\left(0, t_{2}, 0\right)\left(0<t_{2}<1\right) .
\end{array}
$$

Therefore, $E F=\left(t_{1},-1,-\frac{1}{2}\right)$,
$$
\boldsymbol{G D}=\left(-\frac{1}{2}, t_{2},-1\right) \text {. }
$$

Since $G D \perp E F$, we have $t_{1}+2 t_{2}=1$. Thus, $0<t_{2}<\frac{1}{2}$.
$$
\begin{array}{l}
\text { Also, } D F=\left(t_{1},-t_{2}, 0\right), \\
|D F|=\sqrt{t_{1}^{2}+t_{2}^{2}}=\sqrt{5 t_{2}^{2}-4 t_{2}+1} \\
=\sqrt{5\left(t_{2}-\frac{2}{5}\right)^{2}+\frac{1}{5}},
\end{array}
$$

Thus, $\sqrt{\frac{1}{5}} \leqslant|D F|<1$.