How could you even do this? Just solving one single time with A* shouldn’t be very expensive (50ms seems very expensive, btw, unless you have a massive grid, I’d double check your heuristic is working correctly). And once you change the grid in any way whatsoever you need to recalculate absolutely every path that may involve that space… and I can’t think of any way to know for sure whether a path involves it.
The only things you could do, as far as I can think of, is do a partial A*, that is if the full path is from A to Z and you remove a building a M, do a pathfind between J and Q, and replace that portion of the path. The drawback is that this might not get the best solution, though. Another option is to make “mipmap” equivalents for your grid, and pathfinding within that. i.e. divide your grid into several different-sized grids. So like if you have a 100x100 maze, have a 10x10 representation of it, a 25x25, a 50x50, and finally the actual 100x100 grid. Each grid space in the 10x10 actually represents 100 grid spaces, in the 25x25 16 spaces, in the 50x50 4 spaces. As entities are built or removed, you not only update the 100x100 grid, you also update the larger grids. If anything at all exists in those 100 spaces for the 10x10, it’s considered a full space. So what you do is try to pathfind on each level, starting with the 10x10 down to the 100x100. You can extrapolate what an empty space means in any one of the grids, even if you can’t compute a full path with it. Like if there is an empty space in the 10x10, that means everything in that 100 space area in the 100x100 is empty so you don’t need to pathfind through the whole thing. It’s pretty complicated and easy to mess up, but can help in certain situations. Still, if you’re doing tower defense, I imagine that when you really need to get the pathfinding fast (when the whole screen is filled) it’s actually going to slow you down because you’ll start doing a bunch of redundant checks…
So in conclusion I’d just figure out why your algorithm is slow and rerun it whenever a building is plopped down. 