In the UK, you could use an index fund or ETF that invests in instruments indexed to the Consumer Price Index. One option is the iShares Barclays £ Index-Linked Gilts (INXG), which
is an exchange traded fund (ETF) that aims to track the performance of the Barclays World Government Inflation-Linked Bond Index as closely as possible.
You still need to take into account commissions, among other factors, and understand that any investment comes with risk. Note that this ETF aims to track the performance of an inflation-linked bond index. It may not succeed all the time. This isn't a fool-proof strategy, unfortunately, because investing is always a trade-off between risk and return. By excepting a higher return, i.e., one that can keep up with inflation, you do bear a higher level of risk.
Vanguard.co.uk has good general information about inflation-indexed instruments and funds too.