Controlled resistive switching by using an optimized 2 nm thick MoS 2 interfacial layer and the role of top electrodes (TEs) on ascorbic acid (AA) sensing in a TaO x -based resistive random access memory (RRAM) platform have been investigated for the first time. Both the high-resolution transmission electron microscopy (HRTEM) image and depth profile from energy dispersive X-ray spectroscopy confirm the presence of each layer in IrO x / Al 2 O 3 /TaO x /MoS 2 /TiN structure. The pristine device including the IrO x TE with the 2 nm thick interfacial layer shows the highest uniform rectifying direct current endurance >1000 cycles and a large rectifying ratio >3.2 × 10 4 , and a high nonlinearity factor >700 is obtained, greater than that of Pt and Ru TEs. After formation, this IrO x device produces bipolar resistive switching characteristics and a long program/erase (P/E) endurance >10 7 cycles at a low operation current of <50 μA with small pulse width of 100 ns. The stressed device shows a reduced Al 2 O 3 /TaO x interface from the HRTEM image, which is owing to O 2− ions' migration toward TiN electrode. By adjusting the RESET voltage and current level, consecutive >100 complementary resistive switching as well as long P/E endurance of >10 6 cycles are obtained. Schottky barrier height modulation at a low field is observed owing to reduction− oxidation of the TE, which is evidenced through reversible AA detection. At a higher field, Fowler−Nordheim tunneling and hopping conduction are observed. Ascorbic acid detection with a low concentration of 1 pM by using a porous IrO x /Al 2 O 3 / TaO x /MoS 2 /TiN RRAM device directly is an additional novelty of this work, which will be useful in future for early diagnosis of scurvy.