Intriguing nanostructuring anomalies have been recently observed in imidazolium ionic liquids (ILs) near their glass transition points, where local density around a nanocaged solute progressively grows up with temperature. Herewith, we for the first time demonstrate experimentally and theoretically, that these anomalies are governed by alkyl chains of cations and crucially depend on their length. Electron Paramagnetic Resonance (EPR) spectroscopy on a series of ILs [Cnmim]BF4 (n = 0-12) shows that only the chains with n = 3-10 favor anomaly. Moreover, remarkable even vs. odd n peculiarities were systematically observed. Finally, similar anomaly was for the first time observed for a non-IL glass of dibutyl phthalate, which structurally mimics cations of imidazolium ILs. Therefore, such anomalous density behavior in a glassy state nanocage goes far beyond ILs and proves to be a more general phenomenon, which can be structurally tuned and rationally adjusted for various potential applications in nanoscale materials.