The claim is true, and the proof proceeds along similar lines to the classical $ a_n = n $ case.
Fix $ \epsilon > 0 $, and define the sets
$$ A_n = \{ x \in \mathbb R^{+} : |f(a_n x)| \leq \epsilon \} $$
$$ B_n = \bigcap_{m \geq n} A_m $$
By continuity of $ f $, both $ A_n $ and $ B_n $ are closed. Furthermore, the given condition implies that
$$ \mathbb R^{+} = \bigcup_{n} B_n $$
By the Baire category theorem, it follows that one of the $ B_n $, say $ B_M $, contains a nonempty open interval, say $ (a, b) $. Pick $ \delta > 0 $ such that $ b(1 - \delta) > a $. By the convergence $ a_{n+1} / a_n \to 1 $, we can pick $ N $ sufficiently large such that for all $ n > N $, we have $ a_n > (1 - \delta) a_{n+1} $. Thus, we have that
$$ a_n b > a_{n+1} (1 - \delta) b > a_{n+1} a $$
and the intersection $ (a_n a, a_n b) \cap (a_{n+1} a, a_{n+1} b) $ is nontrivial for $ n > N $. The divergence $ a_n \to \infty $ then implies that
$$ S = \bigcup_{n > \max\{M, N\}} (a_n a, a_n b) = (C, \infty) $$
for some $ C $. By definition of $ B_M $ and the inclusion $ (a, b) \subset B_M $, it follows that for all $ x \in S $, we have that $ |f(x)| \leq \epsilon $. Since $ \epsilon > 0 $ was arbitrary, it follows that $ f(x) \to 0 $ as $ x \to \infty $.