Looking for an accurate and fast updating range sensor
Inside an inkjet printer, I've found a clear plastic strip with photo-engraved (loose approximation) lines perpendicular to the length of the strip. This strip passes through an optical pair, one side illuminates, the other reads. The strip stretches the entire width of the printer and if I recall correctly, the reading module is on the print head carriage. Consider that many printers are described as 600 dots per inch, which would create a resolution on the strip of 1/600&quot; / 0.04 mm.
Additionally, I've discovered circular plastic encoders on which the rings of black/clear alternated the segment counts with each expanding ring. That is to say, the first ring was half black, half clear. The next ring out was 1/4 black/white alternating, the one following was 8 segments, then 16, etc.
This required a reader for each ring, but provided an absolute reference rather than a relative reference as is the case with the linear strip. One could create a linear strip which would work in a similar manner. One level would be half black, half clear, the next layer would be 1/4 black/clear, etc.

The requirement for 500 mm fits into a binary 512 value, which would require 9 stripes and provide for the accuracy noted in the post.
The aspect I can't answer is the speed of the encoding, although I suspect that any design based on an optical reader could be optimized to work.
I found an article at rp-photonics.com

When light is diffracted at the traveling refractive index grating in
an acousto-optic modulator, the diffracted light experiences a shift
of optical frequency which is plus or minus the acoustic (or drive)
frequency. That effect (which can be interpreted as a Doppler shift)
is exploited in acousto-optic frequency shifters.
Drive frequencies are typically between some tens and hundreds of
megahertz, rarely more than 1 GHz. The resulting change of optical
wavelength is quite small. For larger frequency shifts, or for
realizing very small frequency shifts (e.g. only a few MHz), one may
cascade two or more devices. It is also possible to use a double pass
through a single device in order to obtain twice the frequency shift.

I think from reading that excerpt that the long strip in the inkjet printer is the traveling refractive index grating. I had not considered that a low-power laser could be substituted for a simple optical pair. Doing so would provided even better resolution.
If your project allows for a strip of sufficient length to be attached to the piston, with assurance that it won't buckle under acceleration and jam in the sensor, you'd probably make it work.
But wait, there's more. I can picture the rod on the piston alternately obscuring and uncovering a digital design, which is constantly scanned by a laser. This reduces the number of parts in close contact and possibly the moving mass.